Home >Web Front-end >JS Tutorial >Jquery binds click event for radio button checkbox_jquery

Jquery binds click event for radio button checkbox_jquery

WBOY
WBOYOriginal
2016-05-16 17:46:231114browse

1. Suppose there is the following html code

Copy code The code is as follows:





Select event (modify the background of the previous layer based on the selection):
Copy code The code is as follows:

var $test_image_check_box_click = function() {
if ($(this).attr("checked") == "checked") {
$(this).parent().css( {"background":"#dcf4fc"});
}
else {
$(this).parent().css({"background":"#fcf7c7"});
}
check_all_imagezz();
}

Binding event:
Copy code The code is as follows:

$(#checkbox-518).click($test_image_check_box_click);

2. Assume that there are many parallel dd tags in the html, each There is a checkbox in the dd tag, and the class name is imagezz. Each checkbox is bound to the preset $test_image_check_box_click event
Copy code The code is as follows:

$(document).ready(function(){
$(".imagezz").click($test_image_check_box_click);
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn