js capturing text button

Button button there are two cases:

1 <input type="button" id="button" value="button">

This button capturing text of the code is:

var buttonValue = document.getElementBy("button").value;

2 <button id="button">button</button>

This button capturing text of the code is:

var buttonText = document.getElementBy("button").innerHTML;

or

var buttonText = document.getElementBy("button").innerText;

Guess you like

Origin www.cnblogs.com/snowhite/p/12217069.html