Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/398.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.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
Javascript 使用jquery更改dom_Javascript_Jquery_Html - Fatal编程技术网

Javascript 使用jquery更改dom

Javascript 使用jquery更改dom,javascript,jquery,html,Javascript,Jquery,Html,我想用jquery更改dom 资料来源: <td class="name"><a href="position_details.php?x=-109&amp;y=95">21</a> </td> <td class="name"><a href="position_details.php?x=-109&amp;y=96">22</a> </td> <td class="name"

我想用jquery更改dom

资料来源:

<td class="name"><a href="position_details.php?x=-109&amp;y=95">21</a> </td>
<td class="name"><a href="position_details.php?x=-109&amp;y=96">22</a> </td>
<td class="name"><a href="position_details.php?x=-109&amp;y=97">23</a> </td>

我想把它改成:

<td class="name"><a href="position_details.php?x=-109&amp;y=95">21</a> :.: <a href='http://d3.traaviaan.ir/build.php?gid=16&t=99&action=showSlot&sort=distance&direction=asc&x=-109&y=$3$4'>Add to farm list</a></td>
<td class="name"><a href="position_details.php?x=-109&amp;y=96">22</a> :.: <a href='http://d3.traaviaan.ir/build.php?gid=16&t=99&action=showSlot&sort=distance&direction=asc&x=-109&y=96'>Add to farm list</a></td>
<td class="name"><a href="position_details.php?x=-109&amp;y=97">23</a> :.: <a href='http://d3.traaviaan.ir/build.php?gid=16&t=99&action=showSlot&sort=distance&direction=asc&x=-109&y=97'>Add to farm list</a></td>
::
:.: 
:.: 
可以改变的是:

槲皮素的价值

和锚文本

我试过这个代码,但没有用`

$(".name").each(function(index){
   str = $(this).html();
   str = str.replace(/[<]a href="position_details[.]php[?]x=([-]?)([0-9]+)&amp;y=([-]?)([0-9]+)">(.+)<\/a>/, 
   "<a href='position_details.php?x=$1$2&y=$3$4'>$5</a> :.: <a href='http://d3.traaviaan.ir/build.php?gid=16&t=99&action=showSlot&sort=distance&direction=asc&x=$1$2&y=$3$4'>Add to farm list</a>");
  $(this).html(str)
$(“.name”)。每个(函数(索引){
str=$(this.html();
str=str.replace(/[(.+)/,
" :.: ");
$(this.html(str)
}))

`试试这个:

$('.name').each(function() {

    var that = $(this);
    var hrefPart = that.find('a').attr('href').split('?');

    that.append(".::.<a href='http://d3.traaviaan.ir/build.php?gid=16&t=99&action=showSlot&sort=distance&direction=asc&" + hrefPart[1] + "'>Add to farm list</a>");
});
$('.name')。每个(函数(){
var,该值=$(此值);
var hrefPart=that.find('a').attr('href').split('?');
即。附加(“.:”);
});

第一个链接的位置部分被拆分,这是最简单的方法。

是一些BoScript吗?给我们
$(this).html()
准确的结果…@vp_-arth不,只是为了学习是的@vp_-arth是正确的。它已经在工作了,谢谢@bhusankawadkar…工作得很好。