我有需要更改其值的 tds。这样做:
$(".class td:nth-child(2)").html("new value");
但我正在尝试在此值之前附加 Font Awesome 图标:
$(".class td:nth-child(2)").append("<i class=\"fa fa-arrow-up\"></i>");
将图标放在 html 之后。我希望它在 html 之前。看起来我需要追加,因为 html 会清除类信息。如何动态地将图标放在 html 之前?
最佳答案
您需要使用 .prepend()
:
$(".class td:nth-child(2)").prepend("<i class=\"fa fa-arrow-up\"></i>");
关于javascript - 将用 .html() 更改的 td 之前的前置图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34474993/