想通过script控制IMAGE的width heigh的大小来实现鼠标移动到上面放大的作用为什么我的代码不能显示

baidu_34767154 2016-05-02 08:46:23
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="site_picture.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script>

function mov()
{
document.getElementById("Image1").height = "600"
document.getElementById("Image1").width = "600"
}
function mov2() {
document.getElementById("Image1").height = "300"
document.getElementById("Image1").width = "200"

}
</script>
</head>
<body >
<form id="form1" runat="server">
<div class="d1">
<asp:Image ID="Image1" onmouseover="mov()" onmouseout="mov2()" runat="server" Width="200" Height="300" />
<asp:TextBox ID="TextBox1" runat="server">
</asp:TextBox><asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<br /><br />
<asp:Image ID="Image2" runat="server" Width="200" Height="200" />
<asp:Image ID="Image3" runat="server" Width="200" Height="200" />
<asp:Image ID="Image4" runat="server" Width="200" Height="200" />

</div>

</form>
</body>
</html>
...全文
123 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
baidu_34767154 2016-05-02
  • 打赏
  • 举报
回复
设置了image的尺寸就无法再调整image的大小了
baidu_34767154 2016-05-02
  • 打赏
  • 举报
回复
<asp:Image ID="Image1" onmouseover="mov()" onmouseout="mov2()" runat="server" Width="200" Height="300" /> 这么些就无法修改width height <asp:Image ID="Image1" onmouseover="mov()" onmouseout="mov2()" runat="server" />这样就实现了我的目的。。百思不得姐啊,我在研究研究
  • 打赏
  • 举报
回复
通常应该在 mov 和 mov2 设置断点,贴出你的 vs 工具 js 调试画面。 调试验证了你的getElementById确实正确,设置width属性确实可以(调试)查到结果,那么这时候就可以排除代码问题而是考虑深一层的逻辑上张冠李戴的问题了。例如大小写问题?操作样式是否根本不是你乱写width这种语法? 自己调试,自己思考。

62,270

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧