Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <img src="img/derp/2.jpg"/>
  2.  
  3. //DETECT THE INITIAL SCREEN WIDTH AND CHANGE THE PATH TO LOAD THE APPROPRIATE IMAGES
  4.  
  5. if ($(window).width() < 960) {
  6. $("img").each(function() {
  7. $(this).attr("src", $(this).attr("src").replace("img/derp", "img/port"));
  8. });
  9. }
  10.  
  11. else {
  12. $("img").each(function() {
  13. $(this).attr("src", $(this).attr("src").replace("img/derp", "img/land"));
  14. });
  15.  
  16. }
  17.  
  18.  
  19. //DETECT THE CHANGED SCREEN WIDTH AND SWITCH THE IMAGE PATH IF NECESSARY
  20.  
  21. $(window).on('resize', function() {
  22.  
  23. if ($(window).width() < 960) {
  24. $("img").each(function() {
  25. $(this).attr("src", $(this).attr("src").replace("img/land", "img/port"));
  26. });
  27.  
  28. } else {
  29. $("img").each(function() {
  30. $(this).attr("src", $(this).attr("src").replace("img/port", "img/land"));
  31. });
  32. }
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement