+ 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>

10th Apr 2021, 3:29 PM
Raidel González Cabrera
Raidel González Cabrera - avatar
11 Respostas
+ 7
With its id.
10th Apr 2021, 3:30 PM
JaScript
JaScript - avatar
+ 4
myBtn3 = getElementById("btn3"); For more please save your code on SL Playground and provide a link here.
10th Apr 2021, 3:47 PM
JaScript
JaScript - avatar
10th Apr 2021, 4:56 PM
JaScript
JaScript - avatar
+ 2
I'm trying to do a calculator. Help plz https://code.sololearn.com/WVE6ATE9Xj2A/?ref=app
10th Apr 2021, 5:46 PM
Raidel González Cabrera
Raidel González Cabrera - avatar
+ 1
Thx
10th Apr 2021, 3:47 PM
Raidel González Cabrera
Raidel González Cabrera - avatar
+ 1
let buttonValue = document.querySelector("#bt3").value; document.write(buttonValue); console.log(buttonValue); alert(buttonValue); prompt(buttonValue); confirm(buttonValue);
1st Jun 2022, 11:35 AM
Praween Gupta
Praween Gupta - avatar
+ 1
by using a function document.getElementById("btn3") and store it in a variable for further use
20th Oct 2023, 8:32 PM
Asher Fraz
Asher Fraz - avatar
0
document.querySelector(‘#btn3)
17th Aug 2021, 11:03 PM
Enes Kaqandolli
0
Sweee
31st Aug 2021, 7:31 AM
Louie Blue
0
Use textContent
13th Mar 2022, 3:26 PM
Ahmed Waiz
Ahmed Waiz - avatar
0
You can this mode: let btn = document.querySelector("#btn3").value
12th Dec 2022, 1:19 PM
Matias Stebé
Matias Stebé - avatar