节点我有HTML这样的:更新“文本”与jQuery
<label><input type="radio" /> Lorem</label>
有什么改变“排版”到“存有”的最佳方式?这些不工作:
// nope:
$('input').next().text('Ipsum');
// also nope:
var text = $('input').parent()[0].childNodes[1];
$(text).text('Ipsum');
我可以很容易地更改HTML到:
<label><input type="radio" /><span> Lorem</span></label>
或直接使用replaceWholeText
DOM方法:
$('input').parent()[0].childNodes[1].replaceWholeText(' Ipsum');
或任意数量的其他事情,但我想知道是否有一个干净的jQuery方式来做到这一点。