<script type="text/javascript" src="script/jquery-1.8.3.js"></script>
</head>
<body>
<form action="" method="post">
<input type="text" id="username" name="username" value="123456"><br/>
<input type="submit" οnclick="testing();" >
</form>
<!-- jQuery对象转成DOM对象 -->
<script type="text/javascript" >
function testing(){
var obj1=document.getElementById("username");
window.alert("1、"+obj1.value);
var $username1=$("#username");
alert("2、"+$username1.val());
//转换jQuery转docment两种方式:
var username2=$username1[0];
alert("3、"+username2.value);
var username3=$username1.get(0);
alert("4、"+username3.value);
}
</script>
</body>
</head>
<body>
<form action="" method="post">
<input type="text" id="username" name="username" value="123456"><br/>
<input type="submit" οnclick="testing();" >
</form>
<!-- jQuery对象转成DOM对象 -->
<script type="text/javascript" >
function testing(){
var obj1=document.getElementById("username");
window.alert("1、"+obj1.value);
var $username1=$("#username");
alert("2、"+$username1.val());
//转换jQuery转docment两种方式:
var username2=$username1[0];
alert("3、"+username2.value);
var username3=$username1.get(0);
alert("4、"+username3.value);
}
</script>
</body>