<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="JQueryPro._Default" %>
<!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">
<title>JQuery測試</title>
<script type="text/javascript" charset="gb2312" src="Js/jquery3.2.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div id="idHelloworld"><p>Hello</p></div>
<input type="text" id="idKey" value="" />
<input type="button" id="idButton" value="add function123--" />
<table>
<tr><td><input type="button" value="testJQuery" onclick='alert($("#idHelloworld").html("hellworld 王德田"))' /></td></tr>
<tr><td><input type="button" value="testJQuery" onclick='alert($("#idKey").attr({value:"test"}))' />修改屬性值</td></tr>
<tr><td><input type="button" value="testJQuery" onclick='alert($("#idKey").val())' />擷取屬性值</td></tr>
<tr><td><input type="button" value="testJQuery" onclick='alert($("#idKey").append("123123"))' />擷取屬性值</td></tr>
<tr><td><input type="button" value="testJQuery" onclick='aOnclick()' />事件</td></tr>
<tr><td><input type="button" value="testAjaxJQuery" onclick='ajaxLoading()' />AjaxLoading事件<div id="Div1">loading</div></td></tr>
<tr><td><input type="button" value="testAjaxPostJQuery" onclick='ajaxPost()' />testAjaxPostJQuery事件<div id="Div2">loading</div></td></tr>
<tr><td><input type="button" value="ajaxGet" onclick='ajaxGet()' />ajaxGet事件<div id="status">loading</div></td></tr>
</table>
</form>
</body>
<script type="text/javascript" charset="gb2312">
//function aOnclick()
//{
//$(document).ready(function() {
$("#idButton").click(function(){alert($("#idButton").val()+"add function");});//增加事件
//}
var obj = {id:"id1",value:"value1",id:"id2",value:"value2"}
function aOnclick()
{
//alert($_GET["url"]);
alert(obj[0].value);
}
function ajaxLoading()
{
$('#stats').load('1.html');
alert("end");
}
function ajaxPost()
{
$.post('ajax.aspx', {
id: 'my string',
number: 23
}, function(data) {
alert(data+'Your data has been saved.');
});
}
function ajaxGet()
{
//'xml',
$.ajax({
url: 'Ajax.aspx?id=123',
type: 'GET',
dataType: 'text',
timeout: 1000,
error: function(){
alert('Error loading XML document');
},
success: function(xml){
alert(xml);
// do something with xml
}
});
}