jQuery test for whether an object has a method?

后端 未结 6 1031
一整个雨季
一整个雨季 2020-12-08 11:09

Is it possible to test whether a jQuery object has a particular method? I\'ve been looking, but so far without success. Thanks!

6条回答
  •  鱼传尺愫
    2020-12-08 11:12

    try

    if ($.fn.method) {
        $('a').method(...);
    }
    

    or

    if ($.method) {
        $.method(...);
    }
    

提交回复
热议问题