Javascript examples for jQuery Method and Property:map
Get All Parent Id's By Same Class Name In Jquery
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript"> $(window).load(function(){/*from w ww .ja v a 2s . co m*/ var arr = $('.class1').map(function(){ return this.parentNode.id }).get(); console.log(arr) }); </script> </head> <body> <div id="id1"> <input class="class1"> </div> <div id="id2"> <input class="class1"> </div> <div id="id3"> <input class="class1"> </div> </body> </html>