Javascript examples for jQuery Method and Property:wrap
Get the id of the wrapping element onclick
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-2.0.0.js"></script> <script type="text/javascript"> $(window).load(function(){//from w w w . j av a2s . c om $('p, span').on('click', function(){ console.log($(this).attr('id')); return false; }); }); </script> </head> <body> <p id="wrapper"> Hello <span id="one"> how </span> are <span id="two">you</span> </p> </body> </html>