gpt4 book ai didi

javascript - 下一个TD的第一个TD

转载 作者:太空宇宙 更新时间:2023-11-04 13:39:09 25 4
gpt4 key购买 nike

我有:

<table>
<tr class="here">
<td class="first">first</td>
<td class="next" par="http://google.com">next</td>
<td class="next" par="http://stackoverflow.com">next</td>
</tr>
</table>

直播:http://jsfiddle.net/C5vSP/

我想用 jQuery 接收:

<table>
<tr class="here">
<td class="first"><a href="http://google.com">first</a></td>
<td class="next" par="http://google.com">next</td>
<td class="next" par="http://stackoverflow.com">next</td>
</tr>
</table>

这必须从第一个 TD.next 获取参数 par 并使用此参数在第一个 TD 中建立链接。

jQuery 可以吗?如果是,如何?

编辑:谢谢你的回答。对于所有+1。我还有一个问题:

<table>
<tr class="here">
<td class="first">first</td>
<td class="next" par="http://google.com">next</td>
<td class="next" par="http://stackoverflow.com">next</td>
</tr>
<tr class="here">
<td class="first">first</td>
<td class="next" par="http://yahoo.com">next</td>
<td class="next" par="http://stackoverflow.com">next</td>
</tr>
<tr class="here">
<td class="first">first</td>
<td class="next" par="http://cnn.com">next</td>
<td class="next" par="http://stackoverflow.com">next</td>
</tr>
</table>

直播:http://jsfiddle.net/C5vSP/2/

此添加为所有 .here 链接 google.com 而不是 google.com、yahoo.com 和 cnn.com。我不能修改html。我只能使用 jQuery。我怎样才能正确地做到这一点?

最佳答案

怎么样: jsFiddle

var url =  $('td.next:first').attr('par');
$('td.first').wrapInner('<a href="'+url+'">');

关于javascript - 下一个TD的第一个TD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8867300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com