mercredi 24 décembre 2014

Cancel HREF when checking a checkbox inside the

I have a css drop down menu:



<ul>
<li>
<a href="http://myurl.com">
Sample Text
<div>
<label><input type="checkbox" name="pub" /></label>
</div>
</a>
</li>
</ul>


and the following javascript:



$(function()
{
$("input[name='pub']").parent()
.change(function(event)
{
//...
});
});


Everytime the checkbox is clicked the href of the "a" is fired because of the "input" is inside of the "a"... There's a way to detect who is clicked, "input" or "a" when i check the checkbox and cancel the href??





Aucun commentaire:

Enregistrer un commentaire