Javascript examples for jQuery:Tag Traversing
get a set of matched dom elements
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.2.js"></script> <script type="text/javascript"> $(function(){//from ww w . j ava2s.c o m var results = []; $("div").each(function(index){ if($(this).data("rindex")) { results[index] = $(this); } }); console.log($(results[0]).html()) }); </script> </head> <body> <div data-rindex="34"> john </div> <div data-rindex="45"> Chris </div> </body> </html>