onClick text change(onClick 文本更改)
问题描述
所以我对 html 很陌生,需要一些帮助.
so I'm pretty new with html and need some help.
我正在尝试制作 3 个按钮,当您单击它们时,每个按钮都会更改旁边的文本.我为每个按钮使用以下代码:
I'm trying to make 3 buttons and each of them will change the text next to when you click on them. I am using the following code for each button:
<a href="#" onClick="document.getElementById('past').innerHTML='---future---';">
当我点击按钮时,innerHTML=" " 之后的文本会发生变化.问题是我在这些地方添加了很多文本---未来---它不会再在浏览器中加载它.屏幕不会更新.我该如何克服这个问题?我已经有这个问题很长一段时间了,所以任何帮助都会得到帮助.
When I click on the button the text will change in the text after the innerHTML=" ". The problem is that one I add to much text on the places ---future--- it won't load it anymore in the browser. The screen just won't update. How do I overcome this problem? I've been having this problem for quite some time so any help will be appriciated.
推荐答案
<script>
function changeText()
{
document.getElementById('boldStuff').innerHTML = 'Fred Flinstone';
}
</script>
<p>Welcome to the site <b id='boldStuff'>dude</b> </p>
<input type='button' onclick='changeText()' value='Change Text'/>
</body>
</html>
试试这个代码.这个对我有用.在上面的代码中,我使用了 [bold] 标签来聚焦它,你可以使用 Acronym 标签.
Try This Code. It Works For Me. In The Above Code I Have Used [bold] tag To Focus It You Can Use Acronym Tag.
这篇关于onClick 文本更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!