帮忙看一下代码哪里错了,审查元素是第12行smallPic attr("showPath",value[0]);那里,但是还是没找到错
<!doctypehtml><html><head><title>pictureshow</title><metacharset="utf-8"/><scripttype...
<!doctype html>
<html>
<head>
<title>picture show</title>
<meta charset="utf-8"/>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
var data={"images/showcA.png":["images/showA.png","showA","300px"],"images/showcB.png":
["images/showB.png","showB","300px"],"images/showcC.png":["images/showC.png","showC","300px"]};
$(function(){
$.each(data,function(key,value){
var smallPic=$("<img src='"+key+"' />");
smallPic attr("showPath",value[0]);
smallPic attr("showName",value[1]);
smallPic attr("showHeight",value[2]);
smallPic.mouseover(function(e){
$("#dataImage").attr("src",$(this).attr("showPath"));
$("#dataName").text($(this).attr("showName"));
$("#dataHeight").text($(this).attr("showHeight"));
$("#details").css("top",e.pageY).css("left",e.pageX).css("display","");
$("body").append(smallPic);
});
});
</script>
</head
<body>
<div style="display:none; position:absolute" id="details">
<img id="dataImage"/>
<p id="dataName"></p>
<p id="dataHeight"></p>
<p><input type="button" value="close"/></p>s
</div>
</body>
</html> 展开
<html>
<head>
<title>picture show</title>
<meta charset="utf-8"/>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
var data={"images/showcA.png":["images/showA.png","showA","300px"],"images/showcB.png":
["images/showB.png","showB","300px"],"images/showcC.png":["images/showC.png","showC","300px"]};
$(function(){
$.each(data,function(key,value){
var smallPic=$("<img src='"+key+"' />");
smallPic attr("showPath",value[0]);
smallPic attr("showName",value[1]);
smallPic attr("showHeight",value[2]);
smallPic.mouseover(function(e){
$("#dataImage").attr("src",$(this).attr("showPath"));
$("#dataName").text($(this).attr("showName"));
$("#dataHeight").text($(this).attr("showHeight"));
$("#details").css("top",e.pageY).css("left",e.pageX).css("display","");
$("body").append(smallPic);
});
});
</script>
</head
<body>
<div style="display:none; position:absolute" id="details">
<img id="dataImage"/>
<p id="dataName"></p>
<p id="dataHeight"></p>
<p><input type="button" value="close"/></p>s
</div>
</body>
</html> 展开
展开全部
<!doctype html>
<html>
<head>
<title>picture show</title>
<meta charset="utf-8"/>
<script type="text/javascript" src="A_stu/4/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
</script>
</head>
<body>
<div style="display:block; position:absolute; top:250px;" id="details">
<img id="dataImage"/>
<p id="dataName"></p>
<p id="dataHeight"></p>
<p><input type="button" value="close"/></p>
</div>
<script type="text/javascript">
var data={"images/showcA.png":["images/showA.png","showA","300px"],"images/showcB.png":
["images/showB.png","showB","300px"],"images/showcC.png":["images/showC.png","showC","300px"]};
$(function(){
$.each(data,function(key,value){
var smallPic = document.createElement("img");
smallPic.setAttribute('src',key);
smallPic.setAttribute("showPath",value[0]);
smallPic.setAttribute("showName",value[1]);
smallPic.setAttribute("showHeight",value[2]);
$("body").append(smallPic);
});
$("img").on('mouseenter',function(e){
$("#dataImage").attr("src",$(this).attr("showPath"));
$("#dataName").text($(this).attr("showName"));
$("#dataHeight").text($(this).attr("showHeight"));
$("#details").css("top",e.pageY).css("left",e.pageX).css("display","");
})
});
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询