日期:2014-05-19  浏览次数:20711 次

jquery mouseover 事件疑问
想实现的功能效果是

在一张图片上 鼠标移上去图片就变大,鼠标移开了 图片变回原样。大虾本请问用jquery 怎么实现。



$("#imagesid").mouseover(function(){
  $(this).css{width:'500px;', height:'900px;'};
}); 



<a href="#"><img src="1.jpg" style="height:65px; width:132px;" id="imagesid"/></a>

我上面写的报错,不行。

------解决方案--------------------
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function test(){
var test = document.getElementById("test");
test.style.width = "500px";
test.style.height = "500px";
};
function test2(){
var test = document.getElementById("test");
test.style.width = "50px";
test.style.height = "50px";
};
</script>
</head>
  
<body>
<img id="test" src="pic/2.jpg" onmouseover="test();" style="width: 50px; height: 50px" onmouseout="test2()"/>
</body>
</html>

------解决方案--------------------
HTML code

<html> 
<head> 
<script src="jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>

$(document).ready(function(){
    $("#imagesid").mouseover(function(){
        $(this).data('oldwidth',$(this).css('width'));
        $(this).data('oldheight',$(this).css('height'));
        
        $(this).css('width','500px');
        $(this).css('height','900px');
    });
    $("#imagesid").mouseout(function(){
        var width = $(this).data('oldwidth');
        var height = $(this).data('oldheight');
        
        $(this).css('width',width);
        $(this).css('height',height);
    });
});
</script>
</head> 

<body> 



<div  style="height:65px; width:132px;" id="imagesid">
<a href="#"><img src="1.jpg" style="height:100%;width:100%"/></a>
</div>

</table>
</body> 
</html>

------解决方案--------------------
HTML code

<html> 
<head> 
<script src="jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>

$(document).ready(function(){
    $("#imagesid").mouseover(function(){
        $(this).data('oldwidth',$(this).css('width'));
        $(this).data('oldheight',$(this).css('height'));
        
        $(thi