-3

I get this error on line below. How to solve this??

jQuery('span.facebookbtn, .fb-like-box').exists(function() {
        load('//connect.facebook.net/en_US/all.js#xfbml=1', 'fbjssdk'); 
}
Jai
  • 74,255
  • 12
  • 74
  • 103

3 Answers3

1

Assuming you want to load the data if the element exists on the page:

Jquery has no "exists" function. Instead we use ".length".

Example:

if (jQuery('span.facebookbtn, .fb-like-box').length)
    load('//connect.facebook.net/en_US/all.js#xfbml=1', 'fbjssdk'); 
Jordumus
  • 2,763
  • 2
  • 21
  • 38
1

Do you have defined exists function? I am not aware that it's a built in function,

Perhaps you should use length functuion instead:

if (jQuery('span.facebookbtn, .fb-like-box').length){
        load('//connect.facebook.net/en_US/all.js#xfbml=1', 'fbjssdk'); 
}
Toni Michel Caubet
  • 19,333
  • 56
  • 202
  • 378
1

There is no exists() function in jQuery (see this question), you either have to define it first (jQuery.fn.exists = function(){return this.length>0;}) or use the length property directly for checking the existence of an element as suggested by the jQuery documentation.

Community
  • 1
  • 1
Baris Akar
  • 4,895
  • 1
  • 26
  • 54