0

嗨,我是 VS2010 的新手,我正在 ASP.NET 中试验 JavaScript。我尝试引用我的示例脚本,但它们不起作用,这是为什么呢?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Member_supplier_details.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $("button").click(function () {
            $("div").animate({ left: '250px' });
        });
    });
</script> 
    <title>test</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <button>Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div>
     <!-- <input name="Qty" type="text" id="Text1" value="0" size="3" tabindex="2000" class="spinner" /> -->
    </div>
    </form>
</body>
</html>
4

2 回答 2

0

更改您的按钮代码。因为没有类型的按钮是提交,所以您的页面已提交。所以将您的类型更改为按钮。

 <button type="button">Start Animation</button>
于 2013-10-07T11:18:14.797 回答
-1

Button 和 DIV 他们没有 ID。您需要在 html 标记中为他们提供 ID,然后在 javascript 中使用这些 id 进行更改

于 2013-10-07T11:10:22.540 回答