Two context objects in a single jQuery selector - Javascript jQuery

Javascript examples for jQuery:Tag Traversing

Description

Two context objects in a single jQuery selector

Demo Code

ResultView the demo in separate window

<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">
    $(window).load(function(){// w  w  w  .  j  av a2 s .  c  om
$(function () {
    $('p', '.test, .test2').text('test');
});
    });

      </script> 
 </head> 
 <body> 
  <div class="test"> 
   <p>masdasd</p> 
  </div> 
  <div class="test2"> 
   <p>masdasd</p> 
  </div>  
 </body>
</html>

Related Tutorials