imgrooot Posted August 24, 2016 Share Posted August 24, 2016 (edited) I have this jquery code below. It basically shows a new div when mouse hover over another div. It works. But I noticed that on page load, it sometimes shows 1 or 2 products already hovered and showing the ".show-details" content. This doesn't happen on every page and sometimes it's only 1 product and sometimes it's 2 products. And they vary in the positions on a page. Do you know why it's doing that and how to fix it? By the way, I have ".show-details" set to display: none by default in the CSS file. <script> $(document).ready(function() { $(".product-small").hover(function() { $(this).find('.show-details').fadeIn("fast").css({ display: 'block'}); }, function(){ $(this).find('.show-details').fadeOut("fast").css({ display: 'block'}); }); }); </script> Edited August 24, 2016 by imgrooot Quote Link to comment https://forums.phpfreaks.com/topic/301989-some-items-are-already-hovered-over-on-page-load-any-way-to-fix-this/ Share on other sites More sharing options...
Solution .josh Posted August 27, 2016 Solution Share Posted August 27, 2016 You can try adding something like this. I've seen it more or less work as a bandaid for some: $(document.ready(function() { $('.product-small .show-details').hide(); }); I don't really have an explanation why it happens though. Quote Link to comment https://forums.phpfreaks.com/topic/301989-some-items-are-already-hovered-over-on-page-load-any-way-to-fix-this/#findComment-1536761 Share on other sites More sharing options...
imgrooot Posted August 28, 2016 Author Share Posted August 28, 2016 You can try adding something like this. I've seen it more or less work as a bandaid for some: $(document.ready(function() { $('.product-small .show-details').hide(); }); I don't really have an explanation why it happens though. It seems to do the trick. Thanks a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/301989-some-items-are-already-hovered-over-on-page-load-any-way-to-fix-this/#findComment-1536776 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.