1:点击按钮:13579....按钮文字 隐藏 div 隐藏
2:点击按钮: 2468.... 文字变 显示 div 显示
<!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></title>
<style>
#box{
width: 100px;
height: 100px;
background-color: red;
}
</style>
</head>
<body>
<div>
<input type="text">
<button id="btn">按钮</button>
<div id="box">张艺兴</div>
</div>
<script>
var btn=document.querySelector('#btn')
var box=document.querySelector('#box')
var ipt=document.querySelector('input')
btn.onclick=function(){
console.log('-------');
var val=ipt.value;
console.log(val);
if(val%2!==0){
box.style.display="none";
}else{
box.style.backgroundColor='green'
box.style.display = 'block';
}
}
</script>
</body>
</html>