以下是jquery中比較常用的一些操作實現方式:
$("標籤名") //取html元素 document.getelementsbytagname("")
$("#id") //取單個控制項document.getelementbyid("")
$("div #id") //取某個控制項中 控制項
$("#id #id") // 通過控制項id取其中的控制項
$("標籤.class樣式名") //通過class來取控制項
$("#id").val(); //取value值
$("#id").val(""); //賦值
$("#id").hide(); //隱藏
$("#id").show(); //顯示
$("#id").text(); //相當於取innerhtml
$("#id").text(""); //相當於innerhtml=""
$("#id").css("屬性","值") //新增css樣式
$("form#表單id").find("#所找控制項id").end() //遍歷表單
$("#id").load("*.html") //載入乙個檔案
例如:
$("form#frmmain").find("#ne").css("border", "1px solid #0f0").end() // end()返回表單
.find("#chenes").css("border-top","3px dotted #00f").end()
$.ajax(,
error:function(msg) //當請求失敗時觸發的函式
});
$(document).ready(function(), //傳遞資料的引數字串
function(data) //觸發後的函式
); });
});
//取得下拉列表的選取值
$(#testselect option:selected').text(); //取文字值
或$("#testselect").find('option:selected').text();
或$("#testselect").val();
JQuery常用方法總結
jquery 選擇器 基本選擇器 id element class selector1,selectorn 層次選擇器 ancestor descendant parent child prev next prev siblings 過濾選擇器 簡單過濾選擇器 first 或 first last ...
jQuery之常用方法總結
1.獲取dom元素 操作方法 jq選擇器 根據選擇器型別快速獲取需要的元素 selector content box imgbox box a a box eq n 獲取集合中索引為n的 gt n 大於這個索引的 lt n 小於這個索引的 節點之間關係的屬性 用jq選擇器獲取的元素,我們設定變數名的...
js學習總結 jquery常用方法
可以看一下他的手冊 1 jquery的 函式 function fn1 value function fn2 value var call callbacks 建立乙個 函式的列表集合 call.add fn1 向集合中增加乙個叫做fn1的函式 call.fire 100 觸發fire方法的時候,把...