简体   繁体   English

jQuery在VS2010中不起作用

[英]jQuery Not working in VS2010

Hi I am new to VS2010 and I was experimenting with JavaScript in ASP.NET. 您好我是新来的VS2010,我是在ASP.NET使用JavaScript实验。 I have tried referencing my sample scripts but they are not working, why is that? 我尝试引用示例脚本,但是它们不起作用,为什么呢?

<%@ 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>

Change your button code. 更改您的按钮代码。 becoz button without type is submit so your page is submited. 没有类型的becoz按钮被提交,因此您的页面已提交。 so change your type to button. 因此将您的类型更改为按钮。

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

Button and DIV they do not have IDs'. 按钮和DIV它们没有ID。 You need to give them ID in html tag, then use those id's in javascript to do the changes 您需要在html标记中为其提供ID,然后在javascript中使用这些ID进行更改

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM