jquery - Can't submit form using .closest() -


i'm having trouble submit form using .closest() method.

here html:

<div class="avatar">     <form method="post" action="out" accept-charset="utf-8">         <input type="hidden" name="id" value="9">         <img src="img/avatars/698dc19d489c4e4db73e28a713eab07b.jpg" class="img-rounded">     </form> </div> 

here js:

$(".avatar").bind('click',function(){     $(this).closest("form").submit(); }) 

if use id instead of class, works.

thanks.

.closest() traverses ancestors, form child. try using .find() locate form.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -