2016年10月24日 星期一

jquery 自訂函數

自訂函數
$.fn.xxfunctionName = function() { ***** }

呼叫
$(selector).xxfunctionName(function(){
var selector=$(this);
});

參數問題 foo() , foo(a) , foo(a,b)
function foo(a, b) {   var aa = typeof a !== 'undefined' ? a : 42;   var bb = typeof b !== 'undefined' ? b : 'default_b';   ... }
e.stopPropagation(); 停止父層程序
e.preventDefault(); 停止預設訂做


 $('a[href$="ABC"]')...
= is exactly equal != is not equal ^= is starts with $= is ends with *= is contains ~= is contains word |= is starts with prefix (i.e., |= "prefix" matches "prefix-...")