1个回答
展开全部
$(function(){
var area1 = $("#area1");//A区域
var area2 = $("#area2");//B区域
area1.mouseenter(function() {
area2.attr("src","2.jpg");//鼠标进入更换连接
}).mouseleave(function(){
area2.attr("src","1.jpg");//鼠标离开换回原连接
})
})
下面这个是不用jquery的可以
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="area1" style="height:50px;width:50px;background:#666;"></div>
<img id="area2" src="hcjp.jpg" style="height:100px;width:100px;" />
<script type="text/javascript">
function changeImg(src) {
var tempSrc = "";
var area1 = document.getElementById("area1");
var area2 = document.getElementById("area2");
area1.onmouseover = function() {
tempSrc = area2.src;
area2.src = src;
}
area1.onmouseout = function() {
area2.src = tempSrc;
}
}
changeImg("1.jpg");
</script>
</body>
</html>
var area1 = $("#area1");//A区域
var area2 = $("#area2");//B区域
area1.mouseenter(function() {
area2.attr("src","2.jpg");//鼠标进入更换连接
}).mouseleave(function(){
area2.attr("src","1.jpg");//鼠标离开换回原连接
})
})
下面这个是不用jquery的可以
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="area1" style="height:50px;width:50px;background:#666;"></div>
<img id="area2" src="hcjp.jpg" style="height:100px;width:100px;" />
<script type="text/javascript">
function changeImg(src) {
var tempSrc = "";
var area1 = document.getElementById("area1");
var area2 = document.getElementById("area2");
area1.onmouseover = function() {
tempSrc = area2.src;
area2.src = src;
}
area1.onmouseout = function() {
area2.src = tempSrc;
}
}
changeImg("1.jpg");
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询