+ 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. .
2 Answers
+ 1
document.getelementbyID(example)
<button id=example type=sumbit>
+ 1
HTML:
<button id="button1" type="submit">1</button>
JS:
let text=document.getElementById("button1").textContent;
console.log(text);