In the first load of the page the image have to display:none. But the problem is, when I put display none, the animate function is not working and I already put a .css({'display':'block'}) still not working.
Here is my code
<script type="text/javascript">
$(document).ready(function() {
$("img.fade").hover(function() {
$(this).stop().animate({ "opacity": "1" }, 300);
$(this).css({ 'display': 'block' });
}, function() {
$(this).stop().animate({ "opacity": "0" }, 300);
});
});
</script>
<style type="text/css">
img.fade { display:none }
</style>
<img src="image.jpg" class="fade" />
If I remove the display:none style, it is working but when the page first loads, image is showing. I need to hide it in the first load then when hovering it will show.