Javascript examples for jQuery Method and Property:closest
Get a form Id an attribute located in
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> <script type="text/javascript"> var handler = function(elem){ console.log($(elem).closest('form').attr('id')) }; </script> </head> /*w w w. j a va 2 s .c o m*/ <body> <form id="formId"> <div> <input type="radio" onclick="handler(this)"> </div> </form> </body> </html>