2

以下错误出现在 firebug 中:

 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);
 }

 }
});


}*/
4

3 回答 3

3

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

"Syntax error, unrecognized expression: >"

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

于 2012-09-18T10:59:30.450 回答
1

我发现了问题,它在行中:

 $("* >").tooltip({

它需要

 $("*").tooltip({
于 2012-09-18T10:48:07.020 回答
-1

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

$('.needs_tooltip').tooltip({....
于 2014-04-04T10:11:50.433 回答