vipin Paliwal
vipin Paliwal

Reputation: 62

Get Checkbox Status in jQuery jTemplates

I have following jtemplate

{#foreach $T.d as post}
<input type='checkbox' >
{#/for}

Template render in DIV. I am not able to get checked checkbox in div

my code to find checked box below

$("#div").find(":checkbox:checked").length

It always returns 0.

Upvotes: 0

Views: 165

Answers (1)

mcgrailm
mcgrailm

Reputation: 17640

seems to work ok for me if the checkbox is not checked you will get 0 here is a demo

here is the js

$('#btn').click(function(){
    alert($("#div").find(":checkbox:checked").length)
});

and html

<div id="div">
<input type='checkbox' >
</div>
<input type="button" id="btn" value="test"/>

Upvotes: 0

Related Questions