Detecting a click in a checkbox with jQuery
206
post-template-default,single,single-post,postid-206,single-format-standard,bridge-core-3.0.1,qodef-qi--touch,qi-addons-for-elementor-1.5.3,qode-page-transition-enabled,ajax_updown,page_not_loaded,,vertical_menu_enabled,no_animation_on_touch,side_area_uncovered_from_content,qode-theme-ver-28.7,qode-theme-bridge,disabled_footer_top,qode_header_in_grid,wpb-js-composer js-comp-ver-6.8.0,vc_responsive,elementor-default,elementor-kit-6

Detecting a click in a checkbox with jQuery

Detecting a click in a checkbox with jQuery

A simple script to detect when a checkbox is clicked. What you do with once you’ve detected the click is up to you.
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.3.2");
google.setOnLoadCallback(function() {
$('#agree').click( function() {
if($(this).attr('checked')){
alert('checked');
}
else{
alert('unchecked');
}
});
});
</script>
</head>
<body>
<p>
<input id="agree" type="checkbox" /> I agree
</p>
</body></html>



Mastodon