i am making a clicker game and need to find out which button is being clicked.
i am not sure how to do this.
this is my javascript
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);
and this is my 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>
how do i find which one is clicked
i also cant find how to get rid of [object HTMLParagraphElement]