Javascript examples for jQuery:Tag Traversing
check if an element exists?
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.5.2.js"></script> <script type="text/javascript"> $(window).load(function(){/*www .ja va2s . c om*/ $('div').length ? console.log('div found') : console.log('Div not found') }); </script> </head> <body> <div></div> <p></p> </body> </html>