[英]Add text - Inner html by jquery
<ul class="list">
<li id="item">How are</li>
</ul>
I want to add "You" to "How are you".我想在“你好吗”中加上“你”。 Pure JS
纯JS
document.getElementById("item").innerHTML += "You";
jQuery? jQuery? How to code it by jQuery?
如何通过jQuery对其进行编码?
You can use jquery's .text()
or .html()
to set or get the text/html content.您可以使用 jquery 的
.text()
或.html()
来设置或获取 text/html 内容。
Below is the example.下面是示例。
let item = $('#item'); item.text(item.text() + ' You');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul class="list"> <li id="item">How are</li> </ul>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.