我得到了这段代码,我想替换顶层和底层之间的“ARRIVAL”文本 <div>
元素,但我想不出办法。
我不想使用 replaceWith
, html
或 <div class="left booktext">
上的类似方法因为那会替换其余的 html 元素。 input class="bookfields"
附加了一个事件处理程序我不想失去它。不幸的是,没有事件委托(delegate)。
<div class="left booktext">
ARRIVAL
<div class="bookborder">
<input type="hidden" name="checkin" value="2014-03-05">
<input type="text" class="bookfields hasDatepicker" style="width:65px;" id="checkin-select" placeholder="dd/mm/yyyy">
</div>
</div>
最佳答案
您可以使用 contents() 和 replaceWith() :
$('.left').contents().first().replaceWith("New Text");
关于javascript - 替换 div 内的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22193330/