jQuery set img element src - Javascript jQuery

Javascript examples for jQuery:Image

Description

jQuery set img element src

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">
    $(function(){//from   w w  w  .j  ava 2  s . com
$('img').attr('src', function() {
    return 'http://www.java2s.com/style/download.png';
});
    });

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

Related Tutorials