input(type="checkbox"|type="radio")+jquery使用

1、用.is(":checked")判断input是否为选中状态

例:

var value=$(this).is(":checked");
localStorage.setItem("displayevelute",value);

 2、用.change()判断input状态是否改变

$("#Isdisplayevelute").change(function(){
var value=$(this).is(":checked");
localStorage.setItem("displayevelute",value);
}


3、用jquery选中name为paystate的所有单选框$("input:radio[name='paystate']"),然后.each()去遍历看那个单选框为选中状态
$("input:radio[name='paystate']").each(function(index){
var status=$(this).is(":checked");
localStorage.setItem("displayevelute",value);
})

4、$("input:radio[name='paystate']:eq(index)")可以选中是具体的input(radio)radio,index为索引
5、div父盒下面有很多子元素,可用find来找到哪些input的状态是checked状态,自然当所有子input的状态变成checked状态了,就可将全选input改变成checked
原文地址:https://www.cnblogs.com/yszblog/p/6857626.html