135
rated 0 times
[
140]
[
5]
/ answers: 1 / hits: 22870
/ 8 Years ago, sat, july 2, 2016, 12:00:00
I was working around with form submissions in html. Please take a look at below code
<form id=form1>
<button id=btn1 onclick=clicked();>Submit</button>
</form>
<script>
$(#btn1).click(function (event) {
alert(event triggered);
if(some_condition == true){
// stop firing onclick method but it always submits the form
event.stopImmediatePropogation(); // not working
event.preventDefault(); // not working
event.stopPropogation(); // not working it's for bubbled events
}
});
function clicked(){ alert(clicked me); }
</script>
I want to stop clicked()
function from firing which is attached to inline onclick
attribute. I would like to run my jquery click function and if something goes wrong, I dont want to trigger onclick but it always runs clicked() function. Could any one help me. Any help is greatly appreciated.
More From » jquery