Some books use xml dom, getattribute ("value"), and. value.
. Value also complies with W3C standards and belongs to HTML Dom.
Environment: Firefox 3.5.5 windows
In Firefox, enter the input element manually and use getattribute ("value") to obtain the entered value.
So we can only use. value. I didn't expect Firefox to have this problem. Does Firefox not support xml dom? Bug?
TestCodeAs follows:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml" XML: lang = "Yue-Hans-CN" lang = "Yue-Hans-CN">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> it works ...... </title>
</Head>
<Body>
<Form action = "./" method = "get">
<Input type = "text" name = "Address" id = "Address"/>
<Input type = "button" name = "button1" id = "button1" value = "getattribute ('value')" onclick = "alert (document. getelementbyid ('address '). getattribute ('value'); "/>
<Input type = "button" name = "button2" id = "button2" value = ". value "onclick =" alert (document. getelementbyid ('address '). value); "/>
</Form>
</Body>
</Html>
And this articleArticleCode: http://updatepanel.net/2008/12/31/more-on-getattribute-setattribute-and-the-value-attribute/
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "<a href =" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd </a>">
<HTML xmlns = "" http://www.w3.org/1999/xhtml ">
<Head>
<Title> more on getattribute () and setattribute () </title>
</Head>
<Body>
<Input id = "textbox1" type = "text" value = "123"/>
<Input type = "button" value = "alert (element. getattribute ('value'); "onclick =" alert (document. getelementbyid ('textbox1 '). getattribute ('value'); "/>
<Input type = "button" value = "alert (element. Value);" onclick = "alert (document. getelementbyid ('textbox1'). Value);"/>
<Ol>
<Li> <input type = "button" value = "element. setattribute ('value', '20140901'); "onclick =" document. getelementbyid ('textbox1 '). setattribute ('value', '123'); "/> </LI>
<Li> enter 'abc' into the text box. </LI>
<Li> <input type = "button" value = "element. value = '000000'; "onclick =" document. getelementbyid ('textbox1 '). value = '000000'; "/> </LI>
<Li> <input type = "button" value = "element. setattribute ('value', 'xyz'); "onclick =" document. getelementbyid ('textbox1 '). setattribute ('value', 'xyz'); "/> </LI>
</OL>
</Body>
</Html>