//html:
<input type="text" id="user"/>
<button onClick="beat()">login</button>
//js
function beat(){
//一:原生js获取文本框的值:
var content=document.getElementById("user");//input的id
//二:jQuery获取文本框的值
$("user").val();
window.alert(content.value);
//这个时候比较要用“==”
if(content.value=="admin"){
do...
//跳转页面
//方法1
window.location.href="new.html";
//方法2
window.navigate("new.html");
//方法3,返回上一页面
window.history.back(-1);
//方法4
self.location='new.html';
//方法5
top.location='new.html';
}else{}
}
js获取html文本框值,判断,跳转
最新推荐文章于 2024-04-19 00:30:19 发布