버튼 클릭시 시계 표시를 시도하고 설정 시간 초과 이벤트를 설정하면 현재 시간이 계속 표시됩니다. 하지만 버튼을 클릭 할 때마다 신발이 단 한 번만 움직입니다. 만약 내가 몇 시간 후에 클릭하면 작동하지만 계속 변화하는 시간은 보이지 않습니다.자바 스크립트 타이밍
스크립트
function showTime() {
var dat = new Date();
var h = dat.getHours();
var m = dat.getMinutes();
var s = dat.getSeconds();
var tim = h + " :" + m + ":" + s;
document.getElementById('MainContent_Label1').innerHTML = tim;
document.getElementById('MainContent_TextBox1').value = tim;
var t = setTimeout(showTime(), 1000);
}
function Button2_onclick() {
showTime();
}
ASP 페이지
asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Label ID="Label1" runat="server"></asp:Label>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Button2" type="button" value="button" onclick="return Button2_onclick()" /><asp:Button ID="Button1" runat="server" Text="Button"
onclientclick="showTime()" /><br />
<br />
</asp:Content>
라인을 변경하는 것만 큼 간단에'var에 t =에서는 setTimeout (쇼 타임, 1000),' –