當前位置:編程學習大全網 - 源碼下載 - 共享源代碼javascript

共享源代碼javascript

功能?顯示時間()

{

var?現在=新?date();

var?year = now . get year();

var?month = now . getmonth()+1;

var?day = now . getdate();

var?hours = now . get hours();

var?minutes = now . get minutes();

var?seconds = now . get seconds();

var?時間值=年+“年”

時間值+=月+“月”

TimeValue+=day+“日?”

timeValue+=(小時& lt=12)?“上午”:“下午”

timeValue+=(小時& gt12)?小時-12:小時

timeValue+=((分鐘& lt10)?":0 "::")+分鐘;

timeValue+=((秒& lt10)?":0 "::")+秒;

文檔。getelementbyid ("lblcur _ time ")。innerhtml = "當前時間:"+time value;

}

功能?getTime()

{

setInterval(show_time,1000);

} & ltbody onload = " getTime()" & gt;

這是壹個動態時鐘!!14答案

10題是定義壹個函數,然後根據點擊的按鈕進行兩個數的加減乘除。

例子

功能Opr(控制)

{

var str first _ Num = document . getelementbyid(" txt first ")。價值;//獲取第壹個輸入框的值

var str second _ Num = document . getelementbyid(" txt second ")。價值;//獲取第二個輸入框的值

var strResult

if(Control=="cmdPlus ")?//如果點擊的按鈕ID為cmdPlus,則執行加法操作。

{

strResult = str first _ Num+str second _ Num;

}

else if(...........

...........//總之根據被點擊按鈕的ID進行相應的計算就可以了。

//最後將結果賦給文本框。

document . getelementbyid(" txt result ")。value = strResult

}

  • 上一篇:程序設計 老鼠走迷宮
  • 下一篇:臺州源代碼網站
  • copyright 2024編程學習大全網