Jquery method to get the selected and unchecked checkbox: 1. Get the checked checkbox, the code is [console.log($(this).val())]; 2. To get the unchecked checkbox, the code is [console.log($(this).val())].
The operating environment of this tutorial: windows10 system, jquery2.2.4, this article is applicable to all brands of computers.
Recommendation: "jquery video tutorial"
jquery method to get selected and unselected checkboxes:
Get checked checkboxes:
$("input[name='show_product_line']:checked").each(function() { console.log($(this).val()); });
Get unchecked checkboxes:
$("input[name='id']:not(:checked)").each(function() { console.log($(this).val()); });
Related free learning recommendations: JavaScript (video)
The above is the detailed content of How to get checked and unchecked checkboxes in jquery. For more information, please follow other related articles on the PHP Chinese website!