html5常用的js簡介一

1.頁面加載,jquerymobile未加強效果前

$(document).on("pagecreate",init);


2.jquery filter操作,從選擇其中應用指定fuction搜索具體元素

$("input[name=mode]").filter(function(){this.value===mode}).click();


3.js在null、undefined、0、”“、NaN時的默認值

var mode = urlParams.mode || "default";


4.!!的作用

var test = !!o.flag 等效於 var test = o.flag || false;


5.window.location.search

獲得的結果爲url中問號之後的部分


6.js exec作用

var reg = /([^&=]+)=([^&]*)/g;

var match = reg.match(window.location.search);

匹配的結果爲數組,第一個爲匹配到的最長的一個,第二個爲字匹配中的第一個,依次類推


7.jquerymobile data選擇器的query與set

var option= $(".selector").collapsible("option");

var collapsedIcon = $(".selector").collapsible("option","collapsedIcon");

$(".selector").collapsible("option","collapsedIcon","arrow-r");


8.jquerymobile動態添加元素後渲染消失可以採用主動調用以下js解決

$("#page").trigger("create");


9.jquery.data()方法以鍵值對方式操作數據,像查詢所選元素的數據或添加元素


發佈了22 篇原創文章 · 獲贊 4 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章