javascript - stopPropagation does not stop the parent action -
javascript - stopPropagation does not stop the parent action -
i'm putting input within a-tag. , want stop link when clicking alter value in input. this
html
<div id="contain"> <a href="http://www.stackoverflow.com" target="_blank" id="link"> <input id="clickme" type="text" value="1"></input> purchase </a> </div>
jquery
$('#clickme').focus(function(e){ e.stoppropagation(); }); $('#clickme').click(function(e){ e.stoppropagation(); });
jsfiddle: http://jsfiddle.net/gkvw3/1/ result still goes stackoverflow.com. ideas why is.
edit real scenario got markup below. when click anywhere within tr take link href. problem becomes submitting form (not in markup) cause link.. there want explained above , that's why utilize input within link in test.
<table> <tr> <td><a href="#">headline</a></td> ... <td><input type="submit" id="submitme" value="buy"/></td> </tr> </table>
it should preventdefault()
:
$('#clickme').click(function(e){ e.preventdefault(); });
doing in .focus()
not relevant, need "cancel" .click()
.
updated fiddle.
javascript jquery javascript-events
Comments
Post a Comment