我正在学习 cshtml/js,但我不太确定如何替换文本块。这是我的代码:
<!DOCTYPE html>
<html>
<head>
<p id = "Jonny">Jonny the giant </p>
<p> hi there <b id ="mytext"> dood! </b></p>
<script>
function Replace() {
y = document.getElementById("mytext");
y.innerHTML = "new string"; @* what I want to do --> document.getElementById("Jonny");*@
}
</script>
<button
type = "button" onclick = "Replace()" > 'MAGIC SWAP'
</button>
</body>
</html>
我想用我已经标识的另一块文本和 id 名称替换该块文本