Domanda

I'm trying to get value of TextBox1 the following way:

  document.getElementById("TextBox1").innerText

but for some reason it doesn't work, I tried it in Chrome and IE. when I do:

  document.getElementById("TextBox1").style.backgroundColor

I get the values, so for some reason it doesn't work only with innerText. is there an alternative way to get value of a textbox? thanks!

È stato utile?

Soluzione 2

You need to access its value property:

 document.getElementById("TextBox1").value

Altri suggerimenti

I don't see the tag name but if it is input[type=text] so use .value property

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top