JavaScript DOM - changing HTML
HTML DOM allows JavaScript to change the content of HTML elements.
document.write()
In JavaScript, document.write() can be used to write content directly to the HTML output stream.
php中文网(php.cn) 当前时间是:
Never use document.write() after the document has been loaded. This will overwrite the document.
innerHTML
The innerHTML attribute is used to set or return the HTML between specified tags content.
Syntax:document.getElementById(id).innerHTML=new HTML
php中文网(php.cn) Hello World!
以上段落通过脚本修改文本。
Change HTML attributes
Syntax:document.getElementById(id).attribute=New attribute The value
attribute is an attribute node. Each DOM element has a corresponding attributes attribute to store all attribute nodes. Attributes is a class The container of an array, to be precise, is NameNodeMap. In short, it is a container similar to an array but different from an array. Each numeric index of attributes stores an attribute node in the form of a name-value pair (name="value").
php中文网(php.cn)