Home > Article > Web Front-end > jQuery gets DIV attributes and binds CheckBox
This time I will bring you jQueryGet DIVpropertiesand bind CheckBox, jQuery gets DIV properties and binds CheckBoxWhat are the precautions? The following is a practical case, let’s take a look.
Without further ado, let’s go straight to the code
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>JqueryTest</title> <script src="js/jquery-1.8.3.min.js"></script> <script> $(document).ready(function () { $('input').click(function(e){ e.stopPropagation(); var parent = $(this).parent(); $(this).is(':checked') ? parent.css('background-color','#CCC') : parent.css('background-color','#FFF'); }); $('p').click(function(){ $(this).find(':checkbox').click(); if($(this).css('background-color') == 'rgb(255, 255, 255)'){ $(this).css('background-color', '#CCC'); }else{ $(this).css('background-color', '#FFF'); } }); }); </script> </head> <body> <p> <input type="checkbox" />A </p> <p> <input type="checkbox" />B </p> <p> <input type="checkbox" />C </p> </body> </html>
Screenshot of the effect:
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Using tabs in jQuery EasyUI tab panel
Practical jQuery drawer-style online customer service
The above is the detailed content of jQuery gets DIV attributes and binds CheckBox. For more information, please follow other related articles on the PHP Chinese website!