开发者

how i can don't apply plugin to id if he not exists

Javascript how i can don't apply plugin to id if he not exists.

$('#wyswig_comment').wyswig();

// Initialization   
$.fn.wyswig = function(options)
{               
    if (isi开发者_如何转开发OS() || detectAndroid() || detectAndroidWebKit()) return false;              
    var obj = new Construct(this, options);         
    obj.init();     
    return obj;
};

If #wyswif_comment not exists in DOM in IE i have error. How check in initializtion function hav element with this id or not.


Start your code with:

// Initialization   
$.fn.wyswig = function(options)
{
      if(!this.length) return;

this inside a JQUery plugin function refers to the matched selectors. If the length of the matched element equals zero, exit the function using return.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜