[英]change html p tag text according to a clicked button
I have a 我有一个
image with id = "b1" and html p tag that shows a number or a text ID =“ b1”和html p标签(显示数字或文本)的图像
When the user click the image I want to see the value of its second parameter (here it is 1) added to the p tag inner html 当用户单击图像时,我想查看添加到p标签内部html中的第二个参数的值(此处为1)
Lets say p is first shown as HELLO, after clicking the image it should be shown as HELLO1 假设p首先显示为HELLO,点击图片后应显示为HELLO1
I used this code for the image 我将此代码用于图像
<img src="images/b_1.png" id="b1" onclick="buttonaction(this,1);"></img>
And the script is as follows 脚本如下
function buttonaction(id,imported){
id.src="images/b_3.png";
document.getElementById("main_display").innerhtml+=imported;
};
This did not work. 这没有用。 I am new to this and look forward some explanation as well.
我对此并不陌生,也期待一些解释。
function buttonaction(id,imported){
id.src="images/b_3.png";
document.getElementById("main_display").innerHTML+=imported;
};
should work for you 应该为你工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.