+ 5
DOM Javascript
How can I get the value of this button in javascript? 👉 <button type="button" id="btn3" value="3" onclick="3">3</button>
11 Respostas
+ 7
With its id.
+ 4
myBtn3 = getElementById("btn3");
For more please save your code on SL Playground and provide a link here.
+ 4
Raidel González Cabrera this can be done for example like here:
https://code.sololearn.com/Wz1xFwext2Z3/?ref=app
+ 2
I'm trying to do a calculator. Help plz https://code.sololearn.com/WVE6ATE9Xj2A/?ref=app
+ 1
Thx
+ 1
let buttonValue = document.querySelector("#bt3").value;
document.write(buttonValue);
console.log(buttonValue);
alert(buttonValue);
prompt(buttonValue);
confirm(buttonValue);
+ 1
by using a function document.getElementById("btn3") and store it in a variable for further use
0
document.querySelector(‘#btn3)
0
Sweee
0
Use textContent
0
You can this mode:
let btn = document.querySelector("#btn3").value