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

How to get checked and unchecked checkboxes in jquery

coldplay.xixi
coldplay.xixiOriginal
2020-11-18 14:38:383987browse

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

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!

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