It's probably a stupid mistake but my brain is just not working today.
I have a button and two <h1>
Elements. They animate when you push the button and I wanted it to fade away when you hover over the text.
Also the button hides itself when you push it.
Here is my code:
$(document).ready(function(){
$("#button1").click(function() {
$('#text1').animate({right: '700px'}, 'slow');
$('#text2').animate({right: '900px'}, 'slow');
$(this).toggle();
});
$('#text1', '#text2').mouseover(function(){
$('#text1', '#text2').fadeTo('slow', 0);
});
});
Just the selector.
$('#text1, #text2').mouseover(function(){
$('#text1, #text2').fadeTo('slow', 0);
});
$('#text1', '#text2')
actually uses the $( selector [, context ] )
form - explained here -, meaning that the #text1
must be inside #text2
. That's probably not what you want.
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.