Replace image with JS and DOM


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <!-- script rollover de imagens -->
  2. <script>
  3. var imgPath = 'http://static.gazzag.com/img/';
  4. function switchImg(img, src) {img.src = imgPath + src;}
  5. </script>
  6.  
  7. <img src="http://static.gazzag.com/img/<gazzag:i18nDir />/addfriend.gif" alt="<gazzag:i18n key="addfriend" />" onmouseover="switchImg(this, '<gazzag:i18nDir />/addfriend_hover.gif');" onmouseout="switchImg(this, '<gazzag:i18nDir />/addfriend.gif');" />

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.