Home > Web Front-end > JS Tutorial > How to get checked and unchecked checkboxes in jquery

How to get checked and unchecked checkboxes in jquery

coldplay.xixi
Release: 2020-11-30 13:48:22
Original
4016 people have browsed it

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())].

How to get checked and unchecked checkboxes in jquery

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()); 
});
Copy after login

Get unchecked checkboxes:

$("input[name='id']:not(:checked)").each(function() { 
  console.log($(this).val()); 
});
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template