JensNTI

bildpryl

Dec 11th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // <img src=".jpg" alt="" class="link" data-out="" data-over="">
  2. // exempel <img src="bild1.jpg" alt="" class="link" data-out="bild1" data-over="bild2">
  3. (function () {
  4.     'use strict';
  5.     var img = document.getElementsByClassName("link");
  6.  
  7.     for (var i = 0; i < img.length; i++) {
  8.         img[i].onmouseover = function () {
  9.             this.src = this.getAttribute("data-over") + ".jpg";
  10.         };
  11.         img[i].onmouseout = function () {
  12.             this.src = this.getAttribute("data-out") + ".jpg";
  13.         };
  14.     }
  15. })();
Advertisement
Add Comment
Please, Sign In to add comment