简体   繁体   English

单击 html/javascript 中的按钮时更改图像

[英]Changing image while clicking button in html/javascript

Please i want to change the temperature level in each button click.请我想改变每个按钮点击的温度水平。 In a way to have a white arrow in a first time, two white arrow ia seconde time .... i have images withe 1 arrow, 2 arrow ext.在第一次有一个白色箭头的方式,第二次有两个白色箭头......我有一个带有 1 个箭头,2 个箭头扩展的图像。

在此处输入图片说明

this my image in html :这是我的 html 图像:

   <div id="WBR"><img src="assets/AWImages/V0.png"></div>
   <button  id= "HI"   class="circle" >+</button>

I simulate the button click in javascript like this :我在 javascript 中模拟按钮点击,如下所示:

let addb = document.querySelector('#HI');
addb.addEventListener('click', () =>{
input.value = parseInt(input.value)+1;
if((input.value)<5)
{
socket.emit('Value of hum changed',input.value);
}
else
{
input.value =4;
}
});

I really appreciate ur help ;)我真的很感谢你的帮助;)

 let addb = document.querySelector('#WBR'); let wbr = document.querySelector('#HI'); var f = document.querySelector('#f'); var Score = 0; var win = 5; var gameOver = false; addb.addEventListener("click", function () { if (!gameOver) { Score++ ; if (Score == win) { gameOver = true; addb.style.color = "green"; } f.innerHTML = Score; } });
 <div id="WBR"><img src="assets/AWImages/V0.png"></div> <button id= "HI" class="circle" >+</button> <p id="f">0</p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM