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 文本更改


- Flexslider 箭头未正确显示 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 400或500级别的HTTP响应 2022-01-01