jQuery 常用語法總結

2021-05-23 08:20:42 字數 1067 閱讀 2783

原文**:   http://www.systhinker.com/html/19/n-20519.html

$() jquery物件本身是乙個集合。

ps:注意dom物件和jquery物件是有區別的,呼叫方法時要注意操作的是dom物件還是jquery物件,

dom物件只能用dom的方法,只有jquery物件才能使用jquery定義的方法

如果我們要把jquery物件要轉換為dom物件則必須取出其中的某一項,一般可通過索引取出,比如:

$("#role")[0],$("#role")get(0),$("div").eq(1)[0],$("div").get()[1],$("td")[5]

這些都是dom物件,可以使用dom中的方法。

普通的dom物件一般可以通過$()轉換成jquery物件,比如 $(document.getelementbyid("userid")),這樣就可以用jquery定義的方法了。

1.對下拉框的操作: //獲取select物件: $("#city")[0];或$("#city").get(0); //獲取options的個數: $("#city")[0].length; //獲取選中的索引: $("#city")[0].selectedindex; //新增option: $("#city")[0].options.add(new option(text,value,false,false)) //ie、ff $("#city")[0].options.add(new option(text,value)) //ie //清空select: $("#city")[0].length=0; 或$("#city").empty(); //當前選中的值: $("#city")[0].val(); 2.核取方塊 checkbox的操作    得到所有選中的:注意瀏覽器的相容性 $("input[name='role'][checked]"); //ie $("input[name='role'][checked=checked]");// ie $("input[name='role'][checked=true]");// ff //ie 和 ff $("input[name='role']").each( function() } );  

jQuery 常用語法總結 持續更新ing

color red blog遷移至 color url color blue size large jquery物件本身是乙個集合。size color color red size medium 說明 size color list 注意dom物件和jquery物件是有區別的,呼叫方法時要注意操作...

mysql常用語法 MySQL常用語法

更新資料 update 表名 set 健名 更改的值 where 建 刪除資料 delete from 表名 where 索引 create index 索引名稱 on 表名 鍵名 建立試圖 create view 檢視名 鍵,鍵 as select matchno,abs won lost fro...

Plsql常用語法總結

1 增加表字段 alter table collect image url add id number 19 not null 2 刪除表字段 alter table collect image url drop column sd 3 插入資料 insert into flfg bh,mc,lj,...