通过鼠标的移入与移出,来进行图片的放大以及隐藏。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
img#imgTip {
position: absolute;
border: 1px solid #ccc;
width: 300px;
height: 250px;
display: none;
}
</style>
<script src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(function () {
$(function (e) {
$("#smallimg").mousemove(function () {
$("#imgTip")
.attr("src", "images/xgll.jpg")
.show()
.css({"left": e.pageX + "px", "top": e.pageY + "px"});
});
$("#smallimg").mouseout(function(){
$("#imgTip").hide();
})
});
})
</script>
</head>
<body>
<img src="images/xgll.jpg" width="150" height="100" id="smallimg" />
<img id="imgTip" />
</body>
</html>