Avatar of Brad Bansner
Brad Bansner
 asked on

Using jQuery to hide image within div that was moused over

I want to hide the image within this DIV when moused over, but this doesn't seem to be working. Any suggestions?

Thank you!

$('.midbutton1').hover(function(){
      $(this).next('.midbuttonarrow').hide();
});

<div class="midbutton1">
<img class="midbuttonarrow" src="img/gr_midbutton-gray.png" width="10" height="6" border="0" />
</div>

Open in new window

JavaScript

Avatar of undefined
Last Comment
Brad Bansner

8/22/2022 - Mon
Ovid Burke

Try this:

$('.midbutton1').hover(
	function() {
		//$('img', this).hide();
		$(this).children('img').hide();
	},
	function() {
		//$('img', this).show();
		$(this).children('img').show();
	}
);

Open in new window


The lines that are commented out will also work as an alternative.
ASKER CERTIFIED SOLUTION
Ovid Burke

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Brad Bansner

ASKER
Thanks!
Your help has saved me hundreds of hours of internet surfing.
fblack61