Sometimes you may need to use scripts to bind events to some forms: for example, Jquery binds a click event to a single-sheet checkbox, And I search and sort out some common skills, for more information, see section 1. Suppose you have the following html code.
The Code is as follows:
Selected events (modify the previous background based on the selected conditions ):
The Code is as follows:
Var $ test_image_check_box_click = function (){
If ($ (this). attr ("checked") = "checked "){
Certificate (this).parent().css ({"background": "# dcf4fc "});
}
Else {
Certificate (this).parent().css ({"background": "# fcf7c7 "});
}
Check_all_imagezz ();
}
Bind event:
The Code is as follows:
$ (# Checkbox-518). click ($ test_image_check_box_click );
2. Assume that there are many parallel dd tags in html. Each dd tag has a checkbox and the class name is imagezz. Each checkbox is bound to a preset $ test_image_check_box_click event.
The Code is as follows:
$ (Document). ready (function (){
$ (". Imagezz"). click ($ test_image_check_box_click );
}