Created
September 1, 2015 10:05
-
-
Save magician11/4991096810c8e441b2d2 to your computer and use it in GitHub Desktop.
How to set a fallback image for a slider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section class="slider"> | |
<img src="andrew-and-artist.jpg" onerror='this.src="./andrew-and-artist.jpg"' /> | |
<nav class="slider-nav"> | |
<ul> | |
<li class="arrow"> | |
<a href="#"><i class="fa fa-long-arrow-left"></i></a> | |
</li> | |
<li class="arrow"> | |
<a href="#"><i class="fa fa-long-arrow-right"></i></a> | |
</li> | |
</ul> | |
</nav> | |
</section> | |
<script type="text/javascript"> | |
$('.arrow').on('click', function(e) { | |
e.preventDefault(); // stop the page reloading | |
$('.slider img').prop('src', 'http://lorempixel.com/1000/600/abstract?' + Math.random()); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment