Understanding DOM hierarchy in jQuery - Javascript jQuery

Javascript examples for jQuery:Tag Traversing

Description

Understanding DOM hierarchy in jQuery

Demo Code

ResultView the demo in separate window


<html>
   <head> 
      <script src="https://code.jquery.com/jquery-1.7.2.min.js"></script> 
   </head> 
   <body> 
      <div id="accordionWrapper"> 
         <p> 
            <a class="expandall" href="#">Test</a> 
         </p> 
      </div> 
      <script>
jQuery('#accordionWrapper p a.expandall').click(function() {
  console.log('It works!');
});/*w ww.  j a  va 2  s  .c om*/

      </script>  
   </body>
</html>

Related Tutorials