我正在使用PHP编写一个示例程序。其中我包含了JavaScript并使用日期,但每次都得到相同的日期。让我们看一下代码。
<?php
?>
<html>
<head>
<title>my app</title>
<script type="text/javascript" src="jquery-2.0.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var time1=new Date();
var time_stack=new Array();
var time;
$(this).mousemove(function(){
time=time1.getSeconds();
alert(time1);
});
});
</script>
</head>
<body>
<h2>we are on the main_session</h2>
</body>
</html>
现在的问题是,当我移动鼠标时,会弹出一个提示框,显示的日期始终相同。请告诉我问题所在。
onmousemove
事件中调用alert()
函数 ;) 最好将该值显示在某个<div>
中。 - Vivek Jain