Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
要在jquery中打印URL中变量的值吗_Jquery - Fatal编程技术网

要在jquery中打印URL中变量的值吗

要在jquery中打印URL中变量的值吗,jquery,Jquery,在上面的代码中,我想打印变量Country的值来代替XXXXX 有人能帮我一下吗?你能不能把字符串连起来 function Entry(content){ var Country=content; ... $(".helplink").attr("href","123/456/789//html/help.htm?href=" XXXXX ".htm") } 我不确定我是否正确地理解了你,但我没有足够的声誉来评论。如果这不是您想要的,请澄清您的问题?使用slice获取属性的第一部分

在上面的代码中,我想打印变量Country的值来代替XXXXX


有人能帮我一下吗?你能不能把字符串连起来

function Entry(content){
  var Country=content;
  ...
  $(".helplink").attr("href","123/456/789//html/help.htm?href=" XXXXX ".htm")
}

我不确定我是否正确地理解了你,但我没有足够的声誉来评论。如果这不是您想要的,请澄清您的问题?

使用slice获取属性的第一部分和最后一部分,并将所需的值连接到其中

function Entry(content){ 
    var Country=content;
    $(".helplink").attr("href","123/456/789//html/help.htm?href=" + Country + ".htm") 
}
var v =  $(".helplink").attr("href");
var index = 'href="';
var character = "country";
v = v.slice(0,v.indexOf(index)+index.length)+character+ v.slice(v.indexOf(index)+index.length + character.length,v.length );
$(".helplink").attr("href", v);