How to select text or value inside a button tag | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to select text or value inside a button tag

As there are tons of rules to select or get any text or it's value inside a button tag. Such as <button type="submit">1</button>... How to select this 1 inside the opening and closing tag of button...please give me the write way to select these type of values or text. .

19th Jan 2019, 5:37 PM
Prabhat Kumar Singh
Prabhat Kumar Singh - avatar
2 Answers
+ 1
document.getelementbyID(example) <button id=example type=sumbit>
19th Jan 2019, 7:39 PM
Jason Kennedy
+ 1
HTML: <button id="button1" type="submit">1</button> JS: let text=document.getElementById("button1").textContent; console.log(text);
21st Jan 2019, 6:16 AM
Игорь Яковенко
Игорь Яковенко - avatar