gpt4 book ai didi

jquery - jquery中鼠标悬停时图像src发生变化

转载 作者:行者123 更新时间:2023-12-01 01:55:32 24 4
gpt4 key购买 nike

html-

<img id="storyimg" src="images/stor.jpg" alt="img" />  
<ul class="sb_menu">
<li><a href="linkpage.htm" class="newslink1">Wireless Networking at Fortune Inn, Noida</a></li>
<li><a href="linkpage.htm" class="newslink2">18th International Conference on Oral & Maxillofacial Surgery</a></li>
<li><a href="linkpage.htm" class="newslink3">WiFi deployment at Vellore Institute of Technology</a></li>
</ul>

我希望当用户移动到这些 li 项目上时我想更改图像,例如 -

<script>
$('a.newslink1').bind('mouseover', function() {
$('img#storyimg').src("images/stor1.jpg");
...same for newslink2 and 3, image will be stor2 and 3

但这不起作用,我想我写了错误的jquery?????????

最佳答案

使用attr:

$('img#storyimg').attr("src", "images/stor1.jpg");

更多信息:

http://api.jquery.com/attr/

关于jquery - jquery中鼠标悬停时图像src发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3416524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com