Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <input type="button" onclick="fn()" >
- <script type="text/javascript">
- $(function() {
- fn()
- $("img.lazy").lazyload();
- });
- function fn(){
- var img = document.createElement('img');
- img.setAttribute('data-original','bg.jpg')
- img.className='lazy'
- document.body.appendChild(img);
- }
- </script>
- <input type="button" onclick="fn()" value="load Image" >
- function fn(){
- var img = $('<img>');
- 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');
- img.attr('class','lazy');
- $(img).appendTo('body');
- setTimeout(function(){
- $("img.lazy").lazyload();
- },100);
- }
- <input type="button" onclick="fn()" value="add image">
- <img data-src="http://lorempixel.com/400/200/" class="lazyload" />
- <script>
- function fn() {
- var img = document.createElement('img');
- img.setAttribute('data-src', 'http://lorempixel.com/400/200/')
- img.className = 'lazyload';
- document.body.appendChild(img);
- }
- fn();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement