I would like for my function to return me the value of the string inside the button, to later be used in other stuff.
I tried (this).innerHTML
and this.innerHTML
to extract the string inside of the button and later be used in the js
HTML:
<button class="fonts" value="2" onclick="change((this).innerHTML)">Times New Roman</button><br>
<button class="fonts" value="1" onclick="change(this.innerHTML)">Calibri</button><br>
<button class="fonts" value="3" onclick="change(this.innerHTML)">Arial</button>
JS:
function change(){
alert();
}
I wanted it to alert "Times New Roman" or the other fonts, yet it alerted a blank value.