I have a simple jquery slideshow that should start when my homepage is loaded. It works, but only after I refresh the page once or twice. Here is the code I am using:
<!-- include jQuery library -->
<script type="text/javascript" src="js/javascript.js"></script>
<!-- include Cycle plugin -->
<script type="text/javascript" src="js/Jquery2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.image').cycle({
fx: 'fade',
random: '1'
});});
</script>
Any help would be greatly appreciated! Thanks in advance!!
-Theo
Change
<script type="text/javascript">
$(document).ready(function() {
$('.image').cycle({
fx: 'fade',
random: '1'
});});
</script>
With
<script type="text/javascript">
$(window).load(function() {
$('.image').cycle({
fx: 'fade',
random: '1'
});});
</script>
I think all images is not loaded
$('img').load(function() {
$('.image').cycle({
fx: 'fade',
random: '1'
});});
});
Read more : Check if images are loaded?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.