天天看點

jQuery 知識點積累

1.判斷checkbox是否選中

   $("#aa").prop("checked")==true

2.給屬性指派

   $("#aa").prop("checked",true) $("#aa").prop("readonly",true) $("#aa").prop("disabled",true)

prop()隻能傳回true和false,對于一般bool類型使用prop,否則使用attr

$("#aa").removeProp("dd")删除自定義的屬性,不要删除原生态的屬性

3.全局設定ajax

$.ajaxSetup({  cache: true, async = false });

4.var p = $("p").detach();删除之後儲存被删除的元素資料

5. $("#Span1").replaceWith("<span title='replaceWith'>Rainier</span>");

             $("<span title='replaceAll'>[email protected]</span>").replaceAll("#Span2");

将<span id="Span1"></span>替換為<span title='replaceWith'>Rainier</span>

("#Span2")替換為<span title='replaceAll'>[email protected]</span>

繼續閱讀