代码之家  ›  专栏  ›  技术社区  ›  Dave

如何在jquery中向现有url添加查询字符串对

  •  1
  • Dave  · 技术社区  · 16 年前

    // Get external links
    $.expr[':'].external = function(obj){
    return !obj.href.match(/^mailto\:/)
            && (obj.hostname != location.hostname);
    };
    

    ?aid=1234567 )

    1 回复  |  直到 16 年前
        1
  •  2
  •   Matthew Groves    16 年前

    
    // custom :external selector
    $.expr[':'].external = function(obj){
        return !obj.href.match(/^mailto\:/)
                && (obj.hostname != location.hostname);
    };
    
    // put the new querystring pair on every external link
    $("a:external").each(function() {
         $(this).attr("href", $(this).attr("href") + "?aid=1234567");
    });