我需要 jquery 代码的帮助。我开发了一个网站,当我们将鼠标悬停在主页、关于我们等导航选项卡上时,标题图像会发生变化。问题是我在“alt”属性中包含了悬停时需要更改的图像。这适用于 chrome,但不适用于 Firefox 和 IE。该网站的链接是
http://datacrawl.in/home.html
HTML:
<ul>
<li><a href="home.html"> Home </a><span style = "color: #FFF; position: relative; left: 23px; "> | </span></li>
<li><a class = "ser" alt = "images/7.jpg" href="about.html"> About Us</a><span style = "color: #FFF; position: relative; left: 23px;"> | </span></li>
<li><a class = "ser" alt = "images/5.jpg" href=""> Services </a> <span style = "color: #FFF; position: relative; left: 23px;"> | </span>
<ul>
<li style = "background-color: #8e64b0;"><a class = "ser" alt = "images/3.jpg" href="software.html"> Software Development </a></li>
<li style = "background-color: #7b55a0;"><a class = "ser" alt = "images/2.jpg" href="web.html"> Web & Graphic Designing </a></li>
<li style = "background-color: #8e64b0;"><a class = "ser" alt = "images/4.jpg" href="technical.html"> Technical Training </a></li>
</ul>
</li>
<li><a class = "ser" alt = "images/6.jpg" href=""> Portfolio </a><span style = "color: #FFF; position: relative; left: 23px;"> | </span>
</ul>
下面给出了我用来执行此操作的 jquery 代码
$(document).ready(function () {
$('.heading1, .heading2, .ser').mouseover(function () {
var src = $(this).attr('alt');
$('.header img').stop().fadeOut(50, function () {
$(this).attr('src', src);
$(this).fadeIn(50);
});
});
$('.heading1, .heading2, .ser').mouseout(function () {
$('.header img').stop().fadeOut(50, function () {
$(this).attr('src', 'images/1.jpg');
$(this).fadeIn(50);
});
});
});
因此,当我将鼠标悬停在标题 1、标题 2 和 ser 类的链接上时,它会将标题图像更改为我设置的相应 alt 属性图像。这在 Firefox 和 IE 中不起作用。请帮我解决一下这个。谢谢你。