开发者

count elements after DOM change

so currently using ajax with JQuery .post to return a form populate with some values. What I am trying to do is basically identify if the content contains checkboxes using:

var count = $('#form').find('checkbox').length;
alert(count);

however even when it does contain checkboxes the output is 0. So do I have the syntax wrong or is it som开发者_StackOverflow社区ething to do with the fact the checkboxes weren't in the original DOM?

many thanks,


There is no tag checkbox, you will need to use the :checkbox docs selector

$('#form').find(':checkbox').length;

or the more verbose

$('#form').find('input[type="checkbox"]').length;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜