I have the following HTML :
<label>
<input type='checkbox' checked="checked" />
CLICK ME....
</label>
and script :
$(document).ready(function(){
$("label").on("click",function(){
if ($(this).children("input[type='checkbox']").is(':checked'))
{
//alert("checked");
// return false;
}
else
{
// alert("not checked");
// return false;
}
});
});
How can i get the checked state ? If its checked i want to perform some operations other ways some other .
I used Live/On because the contend is dynamically added.
Please check this jSfiddle
Tried this and worked (jQuery 1.7.1):
jsFiddle: http://jsfiddle.net/tNGqs/
UPDATE: After your comments I’ve created second jsfiddle: http://jsfiddle.net/8ByqX/
As I understand you want to get rid of firing event on child element. You should define stop propagation on element:
Look also at Hello71’s comment on accepted answer here:
How to check for a click in a parent element, but not in the child?