<ul class="list">
<li id="item">How are</li>
</ul>
I want to add "You" to "How are you". Pure JS
document.getElementById("item").innerHTML += "You";
jQuery? How to code it by jQuery?
You can use jquery's .text()
or .html()
to set or get the text/html content.
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.