In jquery1.5.1 the object returned by ID is the corresponding array, no wonder that using document.getElementById ("ID name") can take a single object, use $ ("#ID名") but not, tragedy.
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> Selector Test </title>
<style type= "Text/css" >
. Txtobj{background-color: #6600FF;}
</style>
<script type= "Text/javascript" src= ". /jquery-1.5.1.min.js "></script>
<script language= "JavaScript" type= "Text/javascript" >
$ (document). Ready (
function ()
{
$ ("input[type= ' text ']")
. click
(
function ()
{
this.value=$ ("#lblMsg") [0].innertext;
}
)
. KeyDown (
function ()
{
Alert ($ ("#divTest") [0].innertext);
Alert ($ ("#lblMsg") [0].innerhtml);
Alert ($ ("#txtTest") [0].value);
return false;
}
);
}
);
</script>
<body>
<table width= "border=" 1 "cellpadding=" 0 "cellspacing=" 0 ">
<tr>
<td><span id= "Lblmsg" >0123456789</span></td>
</tr>
<tr>
<td>
<input type= "text" id= "Txttest" class= "Txtobj" value= "@# $message test"/>
</td>
</tr>
</table>
<div id= "Divtest" >ABCDEFGHIJKLMNOPQRSTUVWXYZ</div>
</body>