Can someone help me with this? When the document loads it automatically does the alert. Not when class b1 or b2 is hovered. How do I fix it to make it when b1 or b2 is hovered to then do the alert?
I am sure it has to do with the document.ready function, but I thought it would not alert till the if statement of hover is initiated. So how do I make it work? Thanks!
function hoverHere(){
if($('.b1').hover()){
alert('Hello World');
};
if($('.b2').hover()){
alert('Hello World');
};
}
$(document).ready(function(){
hoverHere();
})
HTML
<section class="headings">
<div class="b1">content</div>
<div class="b2">content</div>
</section>
alert
is a horrible choice to use in any mouse events that are not clicks.hover()
documentation, you would have noticed that you are doing it wrong.