jQuery test for whether an object has a method?

后端 未结 6 1034
一整个雨季
一整个雨季 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:13

    You should be able to look for undefined

    if( typeof jQuery("*").foo === "undefined" ){
      alert("I am not here!");
    }
    

提交回复
热议问题