1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5 <script type="text/javascript" src="../js/jquery-1.4.2.js"></script> 6 <title>test</title> 7 </head> 8 <body> 9 <input type="text" id="username" value="asdf"> 10 <script type="text/javascript"> 11 12 var $jq=$("#username"); 13 alert($jq.val()); 14 // 以下两种方式等同 //jQuery转换成 dom对象 15 var dom1=$jq[0]; 16 var dom2=($jq).get(0); 17 alert(dom1.value); 18 alert(dom2.value); 19 //转换 dom对象转换成jQuery对象 20 var $jj=$(dom1); 21 alert($jj.val()+"wwwwwwww"); 22 </script> 23 </body> 24 </html>