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
.
精彩评论