原型js中document.body.innerHTML的替代命令
Alternative command of document.body.innerHTML in prototype js
document.body.innerHTML 原型的替代命令。
我需要更改原型中文档的 innerhtml 原型 js 中 document.body.innerHTML 的替代命令是什么。
//<p> Hello, <b>World</b>!</p>
var para = document.createElement('p');
para.appendChild(document.createTextNode('Hello, '));
// <b>
var b = document.createElement('b');
b.appendChild(document.createTextNode('World');
para.appendChild(b);
para.appendChild(document.createTextNode('!'));
// Do something with the para element, add it to the document, etc.
另外,
var node = document.getElementById("one");
while( node.firstChild )
node.removeChild( node.firstChild );
node.appendChild( document.createTextNode("Two") );
如果您有 dom 元素 ID,那么您可以使用:
$('<idOfElement>').update('Text here');
进一步如果你想改变 html 包括标签
$('<idOfElement>').update('<h1>Text here</h1>');
或者如果您想要更改 body 标签本身的内容
document.body.update('Text here');
进一步如果你想改变 html 包括标签
document.body.update('<h5>Text here</h5>');
希望对您有所帮助。
document.body.innerHTML 原型的替代命令。
我需要更改原型中文档的 innerhtml 原型 js 中 document.body.innerHTML 的替代命令是什么。
//<p> Hello, <b>World</b>!</p>
var para = document.createElement('p');
para.appendChild(document.createTextNode('Hello, '));
// <b>
var b = document.createElement('b');
b.appendChild(document.createTextNode('World');
para.appendChild(b);
para.appendChild(document.createTextNode('!'));
// Do something with the para element, add it to the document, etc.
另外,
var node = document.getElementById("one");
while( node.firstChild )
node.removeChild( node.firstChild );
node.appendChild( document.createTextNode("Two") );
如果您有 dom 元素 ID,那么您可以使用:
$('<idOfElement>').update('Text here');
进一步如果你想改变 html 包括标签
$('<idOfElement>').update('<h1>Text here</h1>');
或者如果您想要更改 body 标签本身的内容
document.body.update('Text here');
进一步如果你想改变 html 包括标签
document.body.update('<h5>Text here</h5>');
希望对您有所帮助。