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
Post a Comment