使用 getElementById
方法找到 <p>
元素,
并将其文本更改为“Hello”。
<p id="demo"></p>
<script>
@(41) = "Hello";
</script>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "Hello";
</script>
<p id="demo"></p>
<script>
document.getElementById("demo").innerText = "Hello";
</script>
<p id="demo"></p>
<script>
document.getElementById('demo').innerHTML = "Hello";
</script>
<p id="demo"></p>
<script>
document.getElementById('demo').innerText = "Hello";
</script>