Javascript 如何仅替换第一个节点

Javascript 如何仅替换第一个节点,javascript,jquery,Javascript,Jquery,使用以下HTML代码: <ul class="column"> <li><h2>Name</h2></li> </ul> <ul class="column"> <li><h2>Address</h2></li> </ul> <ul class="column"> <li><h2>Title</h2&

使用以下HTML代码:

<ul class="column">
  <li><h2>Name</h2></li>
</ul>
<ul class="column">
  <li><h2>Address</h2></li>
</ul>
<ul class="column">
  <li><h2>Title</h2></li>
</ul>
但这不起作用


有什么想法吗?

你有很多方法来实现它:

$(".column:eq(0) h2").html("Replacing Name for another name");
或:


你有很多方法来实现它:

$(".column:eq(0) h2").html("Replacing Name for another name");
或:

尝试:

尝试:

试一试

$(".column:eq(0) h2").html("Replacing Name for another name");

有关详细信息,请尝试

$(".column:eq(0) h2").html("Replacing Name for another name");


更多细节

你说的“不工作”是什么意思?你说的“不工作”是什么意思?所有这些都有效!谢谢你们!我需要做一点改变才能让它正常工作<代码>$(“.column:first h2:first”).html(“我的文本”)一切正常!谢谢你们!我需要做一点改变才能让它正常工作<代码>$(“.column:first h2:first”).html(“我的文本”)
$(".column:eq(0) h2").html("Replacing Name for another name");
$(".column:first h2").html("Replacing Name for another name");