开发者

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

开发者 https://www.devze.com 2023-04-12 21:26 出处:网络
Javascript how i can don\'t apply plugin to id if he not exists. $(\'#wyswig_comment\').wyswig(); // Initialization

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

精彩评论

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

关注公众号