2012-09-18 84 views
2

下面的错误出现在Firebug:JQUERY“语法错误,无法识别的表达”收到

Error: Syntax error, unrecognized expression: > 

    jquery line 3 

我不明白这是什么,我试图寻找在我的代码字符,但我无法找到任何东西。我只是发现了一些函数调用:$('#element').html('<strong>hello</strong>');

没有什么更多,有没有人知道更多关于此?

在网页代码:

<script type="text/javascript"> 
    window.fbAsyncInit = function(){ 
     FB.init({ 
     appId: '307355336003233', 
     status: true, 
      cookie: true, 
      xfbml: true 
     }); 
    }; 
    (function() { 
     var e = document.createElement('script'); 
     e.type = 'text/javascript'; 
     e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
     e.async = true; 
     document.getElementById("fb-root").appendChild(e); 
    }()); 

    </script> 
<script type="text/javascript"> 
$(document).ready(function(){ 
    $('.modal').hide(); 
    $(".nav li a i").tooltip({ 
     placement: "bottom" 
     }); 
    $("body").tooltip({ 
    selector: "*[rel=tooltipRIGHT]", 
    placement: "right" 
    }); 

    $("*").tooltip({ 
    selector: "*[rel=tooltipTOP]", 
    placement: "top" 
    }); 
    $("* >").tooltip({ 
    selector: "*[rel=tooltipBOTTOM]", 
    placement: "bottom" 
    }); 
     $('.top-link i').on('click',function(){ 
     $('.top-link i').removeClass('active'); 
     $(this).addClass('active'); 
     }); 
$('.popover-init').popover({ 
    selector:'*[rel=popoverTOP]', 
    placement:'top' 
    }); 
}); 
</script> 

文件functons.js

<!-- FB LOGIN --> 

    function FBlogin(){ 
    FB.getLoginStatus(function(r){ 
     FB.login(function(response) { 
     if(response.authResponse) { 
      $.ajax({ 
      type:'GET', 
      url: _config_base_url+'/login/ajax_login', 
      dataType:'json', 
      data:{'at':response.authResponse.accessToken}, 
      beforeSend:function(){ 
       $('.ajax-loading').show(); 
      }, 
      error:function(_response){ 
       //openError(_response.responseText); 
       $('.ajax-loading').hide(); 

      }, 
      success:function(json){ 
       $('.ajax-loading').hide(); 
       _document_location = window.location.href; 
       /*_json = JSON.parse(json); 
       $("#top-logged-out").fadeOut(0,function(){ 
       $("#top-logged-in").text(_json.first_name); 
       $('#top-user').fadeIn(); 
       });*/ 
      window.location.reload() 
      } 
      }); 
     } else {} 
     },{scope:'email,user_birthday'}); 
    }); 
    } 
    function RemoveAccount(){ 
$.ajax({ 
    type:'POST', 
    url:_config_base_url+'/account/remove', 
    data:{}, 
    dataType:'json', 
    error:function(){ 
    $('.ajax-loading').hide(); 
    }, 
    beforeSend:function(){ 
    $('.ajax-loading').show(); 
    }, 
    success:function(json){ 
    $('.ajax-loading').hide(); 
    $('#remove-account-close').trigger('click'); 
    window.location.href= _config_base_url+'/logout'; 

    } 
}); 
} 
function deleteasd(_id_asd){ 
$.ajax({ 
    type:'POST', 
    url:_config_base_url+'/asds/delete', 
    data:{'id':_id_asd}, 
    dataType:'json', 
    error:function(){ 
    $('.ajax-loading').hide(); 
    }, 
    beforeSend:function(){ 
    $('.ajax-loading').show(); 
    }, 
    success:function(json){ 
    $('.ajax-loading').hide(); 
    $('#'+_id_asd+'-asd-content').fadeOut(400,function(){ 
     $(this).remove(); 
    }); 


    } 
}); 
} 
function createasd(){ 

_title = $('input#title').val(); 
_description = $('textarea#description').val(); 
_keywords = $('input#tags').val(); 

$.ajax({ 
    type:'POST', 
    url:_config_base_url+'/asds/create', 
    dataType:'json', 
    data:{'title':_title,'description':_description,'keywords':_keywords}, 
    error:function(){ 
    $('.ajax-loading').hide(); 
    $('#save-asd').removeAttr('disabled'); 
    $('#create-asd-errors').text('somenthing was wrong, please try later.').fadeIn(0); 
    }, 
    beforeSend:function(){ 
    $('.ajax-loading').show(); 
    $('#save-asd').attr('disabled','disabled'); 

    }, 
    success:function(json){ 
    $('#save-asd').removeAttr('disabled'); 
    _json = json; 
    $('.ajax-loading').hide(); 

    if(_json.error == 1){ 

    $('#create-asd-errors').html('<h5>Errors</h5>'+_json.title+'<br>'+_json.description+'<br>'+_json.keywords).fadeIn(0); 
    }else{ 
    $('.modal-body').html('<div class="alert alert-success"><h5>asd successfully created.</h5></div>'); 
    setTimeout(function(){ 
    window.location.href= _config_base_url+'/profile/51'; 
    },260); 

    } 

    } 
}); 
} 
function vote_init(_element){ 
    _id_asd = _element.attr('name'); 
    _id_user = _element.attr('id'); 
if(_element.hasClass('active')){ 

    vote_less(_id_asd,_id_user); 
}else{ 
    vote_plus(_id_asd,_id_user); 
} 

} 

function vote_plus(_id_asd,_id_user){ 
    $.ajax({ 
    type:'POST', 
    url:_config_base_url+'/votes/vote_plus', 
    dataType:'json', 
    data:{'id_user':_id_user,'id_asd':_id_asd}, 
    error:function(){ 
    $('.ajax-loading').hide(); 
    }, 
    beforeSend:function(){ 
    $('.ajax-loading').show(); 
    }, 
    success:function(json){ 
    $('.ajax-loading').hide(); 

    } 
    }); 
} 
function vote_less(_id_asd,_id_user){ 
    $.ajax({ 
    type:'POST', 
    url:_config_base_url+'/votes/vote_less', 
    dataType:'json', 
    data:{'id_user':_id_user,'id_asd':_id_asd}, 
    error:function(){ 
    $('.ajax-loading').hide(); 
    }, 
    beforeSend:function(){ 
    $('.ajax-loading').show(); 
    }, 
    success:function(json){ 
    $('.ajax-loading').hide(); 

    } 
    }); 
} 
function init_favourite(_element){ 
_id_asd = $(_element).attr('id'); 
_id_user = $(_element).attr('name'); 

if(_element.hasClass('active')){ 
    $(_element).removeClass('active'); 
    remove_favourite(_id_asd,_id_user); 
}else{ 
    $(_element).addClass('active'); 
    add_favourite(_id_asd,_id_user); 

} 
} 

function add_favourite(_id_asd,_id_user){ 
$.ajax({ 
    type:'POST', 
    url:_config_base_url+'/favourites/add', 
    data:{'id_asd':_id_asd,'id_user':_id_user}, 
    dataType:'json', 
    error:function(){ 
    $('.ajax-loading').hide(); 
    }, 
    beforeSend:function(){ 
    $('.ajax-loading').show(); 
    }, 
    success:function(json){ 
    $('.ajax-loading').hide(); 

    } 

}); 
} 
function remove_favourite(_id_asd,_id_user){ 
$.ajax({ 
    type:'POST', 
    url:_config_base_url+'/favourites/remove', 
    data:{'id_asd':_id_asd,'id_user':_id_user}, 
    dataType:'json', 
    error:function(){ 
    $('.ajax-loading').hide(); 
    }, 
    beforeSend:function(){ 
    $('.ajax-loading').show(); 
    }, 
    success:function(json){ 
    $('.ajax-loading').hide(); 

    } 

}); 
} 








    /* $('#nav-search').css('color','#fff'); 
     $('#nav-search').on('focusin',function(){ 
     $(this).css({'box-shadow':'0px 0px 10px 0px #000','border':'1px solid trasparent','color':'#000','background':'#fff','opacity':'3'}); 

     }); 
     $('#nav-search').keydown(function(e){ 
     var _keywords = $(this).val(); 
     /* ONLY WHEN ENTER KEY*/ 
     /*if(e.which === 13){ 
     if(_keywords.length > 0){ 
     SiteSearch(_keywords,_page=1); 
     } 
    } 
     });*/ 



/* 
function SiteSearch(_keywords,_page){ 
$.ajax({ 
type:'POST', 
url:_config_base_url+'/search/ajax_search', 
data:{'keywords':_keywords,'page':_page}, 
dataType:'json', 
error:function(){}, 
beforeSend:function(){}, 
success:function(json){ 
    if($('#home-decore').is(':visible')){ 
    $('#home-decore').fadeOut(300,function(){ 
    $('#wrapper').hide().html(json.view).fadeIn(300); 
    }); 
}else{ 
    $('#wrapper').hide().html(json.view).fadeIn(300); 
} 

} 
}); 


}*/ 
+0

什么版本的jquery?你使用什么代码? – jett

+1

请向我们展示引发此错误的页面/代码 –

+0

请分享您的代码... –

回答

1

我发现这个问题,这是该行:

$("* >").tooltip({ 

它需要

$("*").tooltip({ 
+0

请使用您问题上的编辑链接添加其他信息。后回答按钮应该只用于问题的完整答案。 – Marcelo

+2

@Marcelo看着OP解决了问题,它看起来像是对我的回答。 –

+0

这只是一个答案,如果你真的解释它,让另一个人谁遇到帖子可以理解它。简单地说,问题在'n'线上,他发现问题根本就没有答案。作为jQuery相对较新的人,我不知道他是如何修复它或为什么它是一个问题。 –

3

在控制台中运行$("* >");。 你会得到以下错误

"Syntax error, unrecognized expression: >" 

你想用表达$("* >")得到什么?

+0

所有孩子:P – sbaaaang

+3

所有孩子的哪个要素?如果你想在DOM中的所有元素,然后使用$(“*”)。如果你想要所有的身体标签的孩子都使用$(“body> *”)。 – Anoop

+0

是的没错,那是我的错误:P – sbaaaang

-1

为什么不给每个需要工具提示的元素分配一个类?

$('.needs_tooltip').tooltip({.... 
相关问题