Javascript 如何在jquery中获取li chechbox checked状态

Javascript 如何在jquery中获取li chechbox checked状态,javascript,jquery,checkbox,html-lists,checked,Javascript,Jquery,Checkbox,Html Lists,Checked,如何在jquery中获取li复选框checked状态 我想要像这一个,但它让我无法定义 $('#ul'+$Id+' li:nth-child('+_index+') span input:checkbox').attr("checked") 任何人都可以从中获得帮助。在jQuery对象上使用 $('#ul'+$Id+' li:nth-child('+_index+') span input:checkbox').is(':checked'); 在jQuery对象上使用 $('#ul'+$I

如何在jquery中获取
li复选框
checked状态

我想要像这一个,但它让我无法定义

$('#ul'+$Id+' li:nth-child('+_index+') span input:checkbox').attr("checked") 
任何人都可以从中获得帮助。

在jQuery对象上使用

$('#ul'+$Id+' li:nth-child('+_index+') span input:checkbox').is(':checked');
在jQuery对象上使用

$('#ul'+$Id+' li:nth-child('+_index+') span input:checkbox').is(':checked');

为什么在javascript中使用变量$id?? 是指数变量吗

您可以选中以下复选框:

$(selector).prop('checked', true);
$(selector).prop('checked', false);
$(selector).attr('checked','checked');
$(selector).removeAttr('checked');
alert($(selector).is(':checked'));

为什么在javascript中使用变量$id?? 是指数变量吗

您可以选中以下复选框:

$(selector).prop('checked', true);
$(selector).prop('checked', false);
$(selector).attr('checked','checked');
$(selector).removeAttr('checked');
alert($(selector).is(':checked'));

它的return only false not true它的return only false not true$Id保存ul下面选中的Id,但在javascript中$Id是无效变量$Id保存ul下面选中的Id,但在javascript中$Id是无效变量