Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <input type="button" onclick="fn()" >
  2. <script type="text/javascript">
  3.  
  4. $(function() {
  5. fn()
  6. $("img.lazy").lazyload();
  7. });
  8.  
  9. function fn(){
  10.  
  11.  
  12. var img = document.createElement('img');
  13. img.setAttribute('data-original','bg.jpg')
  14. img.className='lazy'
  15. document.body.appendChild(img);
  16. }
  17.  
  18. </script>
  19.  
  20. <input type="button" onclick="fn()" value="load Image" >
  21.  
  22. function fn(){
  23. var img = $('<img>');
  24. img.attr('data-original','https://www.google.co.in/logos/doodles/2015/126th-anniversary-of-the-public-opening-of-the-eiffel-tower-4812727050567680-hp.jpg');
  25. img.attr('class','lazy');
  26. $(img).appendTo('body');
  27. setTimeout(function(){
  28. $("img.lazy").lazyload();
  29. },100);
  30. }
  31.  
  32. <input type="button" onclick="fn()" value="add image">
  33. <img data-src="http://lorempixel.com/400/200/" class="lazyload" />
  34. <script>
  35. function fn() {
  36. var img = document.createElement('img');
  37. img.setAttribute('data-src', 'http://lorempixel.com/400/200/')
  38. img.className = 'lazyload';
  39. document.body.appendChild(img);
  40. }
  41.  
  42. fn();
  43. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement