-3

这是我的 JavaScript 代码

$(this).find('a:internal:not(.no-ajaxy)').on('click',function(evt) {
        evt.preventDefault();
        History.pushState(null, $(this).text(), $(this).attr('href'));
    });

这是我试图不应用ajax的链接

 <a href="#loginModal" class="btn btn-success no-ajaxy" data-toggle="modal">Login &rsaquo;&rsaquo;</a>

这里的问题是我的脚本给了我这个错误

Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: internal 

我目前正在使用 jQuery v1.8.3

4

2 回答 2

1

从您的评论中,听起来您只需要使用以下内容:

$(this).find('a:not(.no-ajaxy)').on('click', function() {
     // your code...
});

:internal不是 jQuery 中默认可用的选择器。

于 2013-02-08T10:51:33.050 回答
0

我认为您必须创建自定义选择器(http://dpatrickcaldwell.blogspot.ch/2010/03/custom-jquery-selector-for-external-and.html的副本):

jQuery.extend(  
  jQuery.expr[ ":" ],  
  {  
    /* 
      /:\/\// is simply looking for a protocol definition. 
      technically it would be better to check the domain 
      name of the link, but i always use relative links 
      for internal links. 
    */  

    external: function(obj, index, meta, stack)  
    {  
      return /:\/\//.test($(obj).attr("href"));  
    },  

    internal: function(obj, index, meta, stack)  
    {  
      return !/:\/\//.test($(obj).attr("href"));  
    }  
  }  
);  
于 2013-02-08T10:22:58.900 回答