我将 var 更改为 class,但这里可能有一些错误。
在这里,我想要这个段落,用户可以在其中更改下一段的名称。我使用的代码只更改了一个名称,但其余的保持不变。
<script type="text/javascript">
function changey(){
var userInput = document.getElementById('userInput').value;
var list = document.getElementByClassName('kiddo');
for (let item of list) {
item.innerHTML = userInput;
}
}
</script>
<input id="userInput" type="text" value="Name of kid" />
<input onclick="changey()" type="button" value="Change Name" /><br>
Welcome to the site <b class="kiddo">dude</b> This is how you create a document that changes the name of the <b class="kiddo">dude</b>. If you want to say <b class="kiddo">dude</b> more times, you can!
没有错误消息,代码只更改一个名称而不是所有三个。
慕桂英4014372
UYOU
相关分类