Find out which user created div was clicked - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

Find out which user created div was clicked

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-2.1.0.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*  ww w.ja  v a  2s .  c  o  m*/
var newName = document.createElement('p');
newName.innerHTML = "test";
newName.onclick = function() {
console.log("you clicked " + newName.innerHTML + "!")
};
document.body.appendChild(newName);
    });

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

Related Tutorials