<body>
<input type="text" id="tt" maxlength="4" value="如:2019">
<input type="button" value="提交" onclick="ttt()">
<h4 id="ss"></h4>
</body>
</html>
<script>
var myDate = new Date();
document.write( myDate.getFullYear()+"年-"+(myDate.getMonth()+1)+"月-"+myDate.getDate()+"日" )
function ttt() {
var t= document.getElementById("tt").value;//获取输入的年份
console.log(t);
var a= t>0 ? (t%4 == 0 && t % 100 != 0 || t%400==0 ? t+"年是闰年":t+"年不是闰年") :"请输入正确年份,如:2019";//三元运算判断
document.getElementById("ss").innerHTML=a; //输出给h4标签显示
}
</script>