js中怎样把单击事件改为鼠标悬浮事件 代码在下面
<html><style>li{list-style:none;float:left;border:1pxsolidred;/*width:70px;*/cursor:p...
<html>
<style>
li {
list-style: none;
float: left;
border: 1px solid red;
/*width: 70px;*/
cursor: pointer;
}
#xyh2 {
overflow: auto;
}
#xyh1 {
border: 1px solid red;
width: 220px;
height: 220px;
}
</style>
<script>
function xyh_2016(id) {
for(var i = 1; i <= 3; i++) {
document.getElementById("xyhr" + i).style.display = "none";
document.getElementById("xyhy" + i).className = "";
}
document.getElementById("xyhr" + id).style.display = "block";
document.getElementById("xyhy" + id).className = "xyhq";
}
var xyhs = 1;
function changer() {
xyh_2016(xyhs);
xyhs++;
if(xyhs >= 4) {
xyhs = 1;
}
}
window.onload = changer;
</script>
<body>
<div id="xyh1">
<div id="xyh3">
<div id="xyhr1"><img src="图片/无标题41.png" /></div>
<div id="xyhr2" style="display:none;"><img src="图片/无标题42.png" /></div>
<div id="xyhr3" style="display:none;"><img src="图片/无标题43.png" /></div>
</div>
<div id="xyh2">
<ul>
<li id="xyhy1" class="xyhq" onclick="xyh_2016(1);">
<div style="position: absolute; top: 265px; left: 0px;">
<img src="图片/无标题41.png" width="65px"height="65px" />
</div>
</li>
<li id="xyhy2" onclick="xyh_2016(2);">
<div style="position: absolute; top: 265px; left: 80px;">
<img src="图片/无标题42.png" width="65px"height="65px" />
</div>
</li>
<li id="xyhy3" onclick="xyh_2016(3);">
<div style="position: absolute; top: 265px; left: 160px;">
<img src="图片/无标题43.png" width="65px"height="65px" />
</div>
</li>
</ul>
</div>
</div>
</body>
</html> 展开
<style>
li {
list-style: none;
float: left;
border: 1px solid red;
/*width: 70px;*/
cursor: pointer;
}
#xyh2 {
overflow: auto;
}
#xyh1 {
border: 1px solid red;
width: 220px;
height: 220px;
}
</style>
<script>
function xyh_2016(id) {
for(var i = 1; i <= 3; i++) {
document.getElementById("xyhr" + i).style.display = "none";
document.getElementById("xyhy" + i).className = "";
}
document.getElementById("xyhr" + id).style.display = "block";
document.getElementById("xyhy" + id).className = "xyhq";
}
var xyhs = 1;
function changer() {
xyh_2016(xyhs);
xyhs++;
if(xyhs >= 4) {
xyhs = 1;
}
}
window.onload = changer;
</script>
<body>
<div id="xyh1">
<div id="xyh3">
<div id="xyhr1"><img src="图片/无标题41.png" /></div>
<div id="xyhr2" style="display:none;"><img src="图片/无标题42.png" /></div>
<div id="xyhr3" style="display:none;"><img src="图片/无标题43.png" /></div>
</div>
<div id="xyh2">
<ul>
<li id="xyhy1" class="xyhq" onclick="xyh_2016(1);">
<div style="position: absolute; top: 265px; left: 0px;">
<img src="图片/无标题41.png" width="65px"height="65px" />
</div>
</li>
<li id="xyhy2" onclick="xyh_2016(2);">
<div style="position: absolute; top: 265px; left: 80px;">
<img src="图片/无标题42.png" width="65px"height="65px" />
</div>
</li>
<li id="xyhy3" onclick="xyh_2016(3);">
<div style="position: absolute; top: 265px; left: 160px;">
<img src="图片/无标题43.png" width="65px"height="65px" />
</div>
</li>
</ul>
</div>
</div>
</body>
</html> 展开
1个回答
展开全部
用文本编辑器,编辑菜单->替换,查找 onclick ,替换 onmouseover 。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询