Anu*_*nup -1 html javascript jquery
<!DOCTYPE html>
<html>
<body>
<p>Click the button to create an Input field.</p>
<button id="btn" onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var y = document.createElement("LABEL");
var yv = prompt("Enter Caption value:", "");
y.setAttribute("value", yv);
document.body.appendChild(y);
}
</script>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
我想使用上面的代码创建“lebel”。它不起作用。请帮忙...
function myFunction() {
var y = document.createElement("LABEL");
var yv = prompt("Enter Caption value:", "");
y.innerHTML = yv;
document.body.appendChild(y);
}Run Code Online (Sandbox Code Playgroud)
<p>Click the button to create an Input field.</p>
<button id="btn" onclick="myFunction()">Try it</button>Run Code Online (Sandbox Code Playgroud)
使用innerHTML添加内容。
| 归档时间: |
|
| 查看次数: |
17337 次 |
| 最近记录: |