i am making a clicker game and need to find out which button is being clicked. i am not sure how to do this.
这是我的 j。
var multiplyer = 1
var carparts = 0;
document.getElementById("karpartz").innerHTML = carparts;
function onButtonClick() {
carparts = carparts + multiplyer;
document.getElementById("karpartz").innerHTML = carparts;
}
const button = document.querySelector( button );
button.addEventListener( click , onButtonClick);
这是我的html。
<button type="submit">
<img src= "example"
alt="buttonpng" border="0" />
</button>
<button>
upgrade click power
</button>
<button>
upgrade idle scrapping
</button>
<p id="karpartz"></p>
<html>
<body>
<h1>
<script type="text/javascript">
document.write(karpartz)
</script>
</h1>
</body>
</html>
如何找到被点击的人
i 还无法找到摆脱[目标超文本字部分]的方法