samedi 28 février 2015

jQuery handle button click inside a form

i don't understand why a button inside my form can't be reached with my jQuery code.



<form action="">
<div class="field">
<label for='username'>Insert username</label>
<input type="text" id="username" name="username">
</div>

<button type='submit' class='btn btn-lg btn-primary buttonRegister'>Register</button>
</form>


Here are my jQuery on click try codes:



$('.buttonRegister').submit(function(){
//action inside function
});


--------------OR----------------------



$('.buttonRegister').click(function(){
//action inside function
});


--------------OR----------------------



$('.buttonRegister').on("click", function(){
//action inside function
});


None of them worked. I'm SURE that code inside click function works because i tried to take button outside the form and it worked well.


Aucun commentaire:

Enregistrer un commentaire