Hello there I would like to know how can I change the <h3 id="score">
innerHtml
when the button is clicked.
In Vanilla Javascript I can access the element with:
const score = document.querySelector('#score');
and change it by doing this:
score.innerHtml = "13";
something like that.
<template>
<div id="scoreboard">
<h4>{{header_my}}</h4>
<button v-on:click="changeH3()">Change</button>
<h3 id="score">0</h3>
</div>
</template>
<script>
export default {
name: "scoreboard",
data() {
return {
header_my: "Hello Wolrd"
};
},
methods: {
changeH3() {
const h3 = document.querySelector("#score");
h3.innerHtml = "12";
}
}
};
</script>
How can I do this, when changeH3
is called? The innerHtml
of h3
with id
of score
must change to 12
.