jQuery isFunction check error “function is not defined”

后端 未结 2 435
孤街浪徒
孤街浪徒 2021-01-31 14:09

I want to do a check whether a function exist or not before trying to run it. Here is my code:

if ($.isFunction(myfunc())) {
    console.log(\"function exist, ru         


        
2条回答
  •  无人共我
    2021-01-31 15:00

    try this

    if(typeof myfunc == 'function'){
        alert("exist");
    }else{
        alert("not exist");
    }
    

提交回复
热议问题