JQuery select a inside p - Javascript jQuery

Javascript examples for jQuery:Selector

Description

JQuery select a inside p

Demo Code

ResultView the demo in separate window

<!doctype html>
<html>
   <head> 
      <meta charset="utf-8"> 
      <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> 
      <script>
      $(document).ready(function () {
        $('a').click(function () {
          console.log($(this).html());
        });/*from  w  w  w  .j a  v a2 s.  co  m*/
      });
    
      </script> 
   </head> 
   <body> 
      <h1>Test</h1> 
      <p>
         <a href="#">This is a test</a>
      </p> 
      <p>
         <a href="#">This the second link</a>
      </p>  
   </body>
</html>

Related Tutorials