JQuery display onclick on element's child - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

JQuery display onclick on element's child

Demo Code

ResultView the demo in separate window


<html>
 <head> 
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
 </head> //from  ww  w  . java2  s . c  o  m
 <body> 
  <div id="resultsBox"> 
   <ul> 
    <li>Element 1</li> 
    <li>Element 2</li> 
   </ul> 
  </div> 
  <script>
$("#resultsBox li").click(function(){
  console.log("You clicked on li " + $(this).text());
});

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

Related Tutorials