I have really basic question.
How can I get form id by input element id.
<form id="my_form">
<fieldset>
<!--some <div>'s-->
<input id="my_input"></div>
<!--some <div>'s end-->
</fieldset>
</form>
Now if I have
var form_input = $('#my_input');
How can I get id “my_form”?
Thank you.
Use
closest. It searches up the ancestors* of an element to find the first (closest) match.*Note: closest() searches upwards starting with the current element, therefore it can match the current element.