Why isn't my simple code working?
See original GitHub issueBelow is a very basic example, and images load before i scroll onto them. What possibly am i doing wrong?
<!DOCTYPE html>
<html>
<head>
<title>Lazy loading</title>
</head>
<body>
<img class="lazyload" data-src="img1.jpg">
<img class="lazyload" data-src="img2.jpg">
<img class="lazyload" data-src="img3.jpg">
<img class="lazyload" data-src="img4.jpg">
<img class="lazyload" data-src="img5.jpg">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lazyload@2.0.0-beta.1/lazyload.js"></script>
<script>
lazyload();
</script>
</body>
</html>
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Why isn't my simple code working? - Beginning Java
So I'm just wondering if someone could explain why my simple code isn't working.
Read more >24+ Reasons Code Doesn't Work & How To Fix It - WP SITES
Discover the most common reasons your CSS or PHP doesn't work or breaks your site when it really does work properly.
Read more >Why won't my code work!? - The Beginner's Guide to Fixing ...
Why won't my code work!? - The Beginner's Guide to Fixing JavaScript Bugs · Step 1: Check your files · Step 2: Open...
Read more >Coding problems? Learn what to do when you're stuck
Even the best programmers get stuck sometimes. Here are some tips to help you get unstuck and learn from your mistakes.
Read more >Why does my code never work? Is it a problem in my abilities ...
Answer: Most of the time my code does not work when I finish writing it. Actually I am amazed when 100 or so...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this is the right syntax replace your <script> whith this code
<script> $("img.lazyload").lazyload({ effect : "fadeIn" }); </script>@bhansa Sorry for the late reply. It works now! I’m not sure what was i missing. here’s the fiddle - https://jsfiddle.net/prtkvarma/2tm3q7ha/