dpd7195 2013-05-10 03:07
浏览 56

如何使用jquery永久更改数据库数据的样式?

I have a table that displays data from my database. On each row, there is a button that i made with jquery to cross the row out when clicked. When I refresh the page though, the crossed out style doesnt stay. the jquery style change isnt permanent. it there a way to make this change permanent?

$('table').on('click','.dead',function(){

          $(this).parent().siblings().css({textDecoration: 'line-through'});

    });

and the php

<?php while($row = $data->fetch_assoc()) { ?>
<tr>

<td><?php echo $row['title']; ?> </td>
<td><?php echo  $row['requester']; ?></td>
<td><?php echo $row['reward']; ?></td>
<td><?php echo $row['qual']; ?></td>
<td><?php echo $row['time']; ?></td>
<td><?php echo $row['category']; ?></td>
<td><a href="<?php $row['link']; ?>"><button class="btn btn-mini btn-primary" type="button">Do This Hit</button></a></td>
<td><button class="btn btn-danger btn-mini dead" type="button">Dead</button></td>

</tr>
<?php } ?>
  • 写回答

1条回答 默认 最新

  • dt4233 2013-05-10 03:20
    关注

    Your html, .js and .css code is all pulled from the server every time the page is requested. That means whatever styles you apply via .JS will be wiped away the next time the page is requested, that is what you are seeing now.

    You the developer are responsible for programming some sort of stored flag, and read it on $(document).ready() so that when the page is requested and the dom is ready the first thing it will do is check your persisted flag and it can re-apply the the current state of your style (either on or off, or in your case, line-through or no line-through)

    There are many options for how you go about persisting that flag. You could set a cookie, you could use Session storage, you could use LocalStorage, or you could even set a flag in your database. It's up to you to provide the persistence of that state.

    If you are supporting modern browsers you could try setting a flag in localstorage() http://www.jquerysdk.com/api/jQuery.localStorage

    评论

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测