简单的脚本控制面试题
版面上有一个button,一个div,单击button,div中显示当前日期
答案:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<script type="text/javascript">
function btn_click()
{
var date=new Date();
div1.innerHTML=date.getFullYear()+"-"+date.getMonth()+"-"+date.getDate();
}
</script>
</head>
<body>
<input type="button" id="btn" value="click" onclick="btn_click()" />
<div id="div1"></div>
</body>
</html>
Copy Right By Robo_zou