php - How do I change the style of database data permanently using jquery? -
i have table displays data database. on each row, there button made jquery cross row out when clicked. when refresh page though, crossed out style doesnt stay. jquery style change isnt permanent. there way make change permanent?
$('table').on('click','.dead',function(){ $(this).parent().siblings().css({textdecoration: 'line-through'}); });
and 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 hit</button></a></td> <td><button class="btn btn-danger btn-mini dead" type="button">dead</button></td> </tr> <?php } ?>
your html, .js , .css code pulled server every time page requested. means whatever styles apply via .js wiped away next time page requested, seeing now.
you developer responsible programming sort of stored flag, , read on $(document).ready() when page requested , dom ready first thing check persisted flag , can re-apply the current state of style (either on or off, or in case, line-through or no line-through)
there many options how go persisting flag. set cookie, use session storage, use localstorage, or set flag in database. it's provide persistence of state.
if supporting modern browsers try setting flag in localstorage() http://www.jquerysdk.com/api/jquery.localstorage
Comments
Post a Comment