簡體   English   中英

jQuery在VS2010中不起作用

[英]jQuery Not working in VS2010

您好我是新來的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>

更改您的按鈕代碼。 沒有類型的becoz按鈕被提交,因此您的頁面已提交。 因此將您的類型更改為按鈕。

 <button type="button">Start Animation</button>

按鈕和DIV它們沒有ID。 您需要在html標記中為其提供ID,然后在javascript中使用這些ID進行更改

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM