$(".classname").html("test_text");
In this way, we stacked text in html in the class using jquery.
I want to avoid using Jquery grammar as much as possible, but javascript can stack strings in the class with the same meaning What grammar is there?
document.getElementById("test_id").innerHTML = "<p>123</p>"
I stacked it on ID like this
document.getElementByClassName("test_class").innerHTML = "<p>123</p>"
Why doesn't it move?
jquery javascript html css
getElementsByClassName()
returns HTMLCollection
.This is kind of a list. So you have to go around the list to do what you want.
var elems = document.getElementsByClassName('classname');
for (i = 0, len = elems.length; i < len; i++) {
elems[i].innerHTML = '<p>123</p>';
}
© 2024 OneMinuteCode. All rights reserved.