1、不常用的切換函數(shù)$("p").toggle();當(dāng)點擊切換按鈕時,隱藏元素為P行和顯示P行;
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").toggle();
});
});
</script>
</head>
<body>
<button type="button">切換</button>
<p>This is a paragraph with little content.</p>
<p>This is another small paragraph.</p>
</body>
</html>

2、append() 函數(shù)向所匹配的 HTML 元素內(nèi)部追加內(nèi)容$(selector).append(content);
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>

<script type="text/javascript">

$(document).ready(function()
{

$("button").click(function()
{
$("p").append(" <b>W3School</b>.");
});
});
</script>
</head>

<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button type="button">請點擊這里</button>
</body>

</html>

類似的還有:
$(selector).html(content) 改變被選元素的(內(nèi)部)HTML
$(selector).append(content) 向被選元素的(內(nèi)部)HTML 追加內(nèi)容
$(selector).prepend(content) 向被選元素的(內(nèi)部)HTML “預(yù)置”(Prepend)內(nèi)容
$(selector).after(content) 在被選元素之后添加 HTML
$(selector).before(content) 在被選元素之前添加 HTML
3、css操作:函數(shù) css({properties}) 同時為所有匹配元素的一系列 CSS 屬性設(shè)置值:
$(selector).css({properties})
$("p").css({"background-color":"red","font-size":"200%"});
jQuery 擁有兩種用于尺寸操作的重要函數(shù):
- $(selector).height(value)
- $(selector).width(value)
總結(jié)如:
$(selector).css(name,value) 為匹配元素設(shè)置樣式屬性的值
$(selector).css({properties}) 為匹配元素設(shè)置多個樣式屬性
$(selector).css(name) 獲得第一個匹配元素的樣式屬性值
$(selector).height(value) 設(shè)置匹配元素的高度
$(selector).width(value) 設(shè)置匹配元素的寬度
4、AJAX:
jQuery AJAX 請求
$(selector).load(url,data,callback) 把遠(yuǎn)程數(shù)據(jù)加載到被選的元素中
$.ajax(options) 把遠(yuǎn)程數(shù)據(jù)加載到 XMLHttpRequest 對象中
$.get(url,data,callback,type) 使用 HTTP GET 來加載遠(yuǎn)程數(shù)據(jù)
$.post(url,data,callback,type) 使用 HTTP POST 來加載遠(yuǎn)程數(shù)據(jù)
$.getJSON(url,data,callback) 使用 HTTP GET 來加載遠(yuǎn)程 JSON 數(shù)據(jù)
$.getScript(url,callback) 加載并執(zhí)行遠(yuǎn)程的 JavaScript 文件
(url) 被加載的數(shù)據(jù)的 URL(地址)
(data) 發(fā)送到服務(wù)器的數(shù)據(jù)的鍵/值對象
(callback) 當(dāng)數(shù)據(jù)被加載時,所執(zhí)行的函數(shù)
(type) 被返回的數(shù)據(jù)的類型 (html,xml,json,jasonp,script,text)
(options) 完整 AJAX 請求的所有鍵/值對選項
略。。。