Document. getElementById (text1). *** statement parsing !!! Do I need the source code? JScriptcodevarxmlhttp; functionhello () {xmlhttpajax1 (); varadocument. getElementById (a). valu document. getElementById ('text1'). *** statement parsing !!!
Do I need the source code?
JScript code
var xmlhttp; function hello(){ xmlhttp=ajax1(); var a=document.getElementById('a').value; var b=document.getElementById('b').value; var url='demo02.php?a='+a+'&b='+b; xmlhttp.open('get',url); xmlhttp.onreadystatechange=display; xmlhttp.send();} function display() { if(xmlhttp.readyState==4 && xmlhttp.status==200) document.getElementById('text1').value=xmlhttp.responseText; }
HTML code
A
B
And yes:
I used to talk about this method when I was learning javascript.
However, I forgot it.
Today, I asked my buddy,
Document. getElementById ('text1') is used to obtain the text box.
Document. getElementById ('text1'). value is the value of the text box.
But then I changed it.
Document. getElementById ('text1'). innerHTMl can also be obtained.
W3c is too vague to understand,
Ladies and gentlemen, can you give me a general explanation?
If not, please point out ..
------ Solution --------------------
Document is a document object (entire webpage)
GetElementById () is a method of document objects. it is used to obtain elements with an ID attribute.
Therefore
Document. getElementById ('text1') gets the HTML node object with the id text1.
This node object has some attributes, such as value, innerHTML, and innerText.
These attributes are different. you can search for them and there will be a lot of long articles to introduce them in detail. you cannot understand them here.
------ Solution --------------------
Document. getElementById ('text1'). value
????
P has no value attribute, so an error occurs.