javascript - Get src attribute of and img and do an alert -


i have alot of images in table rows. whatever image clicked, want display src in alert box.

$(document).ready(function() {      /* register click events */     $(".tableimages").click(function(){         imageclickevent().call(this);     });   });   function imageclickevent() {      if($(this).is("img"))     {         alert("yes"); //nothing happens     }  } 

<img src="http://img.kooora.com/?i=ali.18%2f2016%2f2%2f5%2f1%2f01_05203041_a54046_2675418a.jpg&z=320|240&c=65|0|1333|1000&h=137" class="btnimg" />  <script>   $(document).on('click' , '.btnimg', function(){     alert($(this).attr('src')) ;  });  </script> 

in brief need have dummy class , assign click event based on class, easy attribute current event soource using $(this) pointer, helpful, work in jquery


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -