<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>判断用户输入的文字是否为123开头</title>
</head>
<body>
<input type="text" id="ip1">
<button id="bt1">判断</button>
<script>
var bt1= document.getElementById("bt1")
bt1.οnclick=function(){
var ip1=document.getElementById("ip1")
var content=ip1.value
var str=content.substr(0,3)
if(str=="123"){
console.log("正确")
}else{
console.log("错误")
}
}
</script>
</body>
</html>