jquery - How to change/add css to dynamically generated checkbox class -


i have jquery accordion, when click on accordion header ajax call brings content. each of these contents has list of items checkboxes , submit button user can update database (via ajax call).

when submit clicked want remove checkbox of checked items , style these specific items. can remove checkboxes can't seem add change css! of items checked. can ? html goes so

html      accordion header <h3>(dynamic id)     div class row     div class bootstrap     checkbox class single-checkbox (dynamic id)     <p> content </p>       checkbox  <input type="checkbox"  class="single-checkbox" name="contentall[]" value="<?php echo $row2['bing'], '-', $row2['content_all']; ?>" />  jquery      $('.submit').click(function() {     $.ajax({     url: "heir3.php",     type: "post",     data: $('.single-checkbox:checked').serialize(),     success: function(data) {     $('.single-checkbox:checked').remove();}        });      });  submit <button class="submit" id="submit">submit</button> 

use addclass() , removeclass() store styles in there:

css

.my-checkbox-class {     // styles } 

jquery

$('.single-checkbox:checked').addclass('my-checkbox-class'); $('.single-checkbox:checked').removeclass('my-checkbox-class'); 

you can add styles element , remove them too. it's good, clean solution makes css re-usable , keeps style , functionality separate.

note add , remove class methods don't need . denote class, can gotcha


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -