how to prevent checkbox check when clicking on link inside label
Posted
by dalbaeb
on Stack Overflow
See other posts from Stack Overflow
or by dalbaeb
Published on 2009-07-08T13:59:48Z
Indexed on
2010/05/12
9:54 UTC
Read the original article
Hit count: 291
jQuery
|JavaScript
Hello,
I have a link inside a label. The problem is, when user clicks 'back' after having read the terms, the checkbox is unchecked, because when they clicked on the link they also unchecked the box at the same time, since the link is inside a label.
<input type="checkbox" id="terms" name="terms" checked="checked" />
<label for="terms">I agree to be bound by the <a href="/terms">Terms</a></label>
How can I prevent the checkbox from being checked when link is clicked? Tried doing event.preventDefault()
on label click, but that doesn't prevent checkbox from being checked/unchecked.
I could just take out the link from inside a label (which means more CSS styling). But now I'm curious whether the above is possible.
© Stack Overflow or respective owner