get img src inside href tag - Javascript jQuery

Javascript examples for jQuery:Image

Description

get img src inside href tag

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-1.8.3.js"></script> 
  <script type="text/javascript">
    $(function(){/*from w w w  .  j  a va  2  s. c o  m*/
$(document).on('click', '.imagemodal', function() {
    var imgsrc = $('img', this).attr("src");
    console.log("IMG: " + imgsrc);
});
    });

      </script> 
 </head> 
 <body> 
  <a href="#" class="imagemodal"> <img src="http://www.java2s.com/style/demo/Safari.png"> </a>  
 </body>
</html>

Related Tutorials