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 文本更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:onClick 文本更改


基础教程推荐
- 检查 HTML5 拖放文件类型 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01