小编yol*_*one的帖子

显示12小时和24小时的时间

我想制作一个显示当前时间的网页.单击"12小时格式"按钮时,12小时内的时间将显示在div区域中.单击"24小时格式"按钮时,时间将显示在div区域的24小时时间内.目前,单击这些按钮时没有任何反应.救命!

HTML:

<html>
<head>
<title>Clock</title>
<script type="text/javascript" src="clock.js"></script>
</head>
<body>
<div id="textbox"></div>
<br/>
<button type="radio" onclick="getTwelveHrs()">12 Hour Format</button>
<button type="radio" onclick="getTwentyFourHrs()">24 Hour Format</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

JavaScript的:

function getTwelveHours{
if (i < 10) {
    i = "0" + i;
}
return i;
}

function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('textbox').innerHTML = h + ":" + m + ":" + s;
t …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery datetime object

5
推荐指数
3
解决办法
2万
查看次数

JavaScript:使用变量的计算器

我有一个问题,我无法让我的JavaScript计算器工作.在浏览器中显示时,该部分显示实际的代码行而不是返回的答案.这就是我到目前为止所拥有的.计算在函数中b(),并打印在document.write()底部.


JavaScript的:

//*Note that this is an external JavaScript file*
function a(a1,a2,a3) {
    this.a1 = a1;
    this.a2 = a2;
    this.a3 = a3;
    this.a4 = b;
}

var abc = new a("2", "80", "1000");
var def = new a("1.5", "40", "512");
var ghi = new a("1", "20", "256");

//Below is the calulation function I'm having problems with
function b() {
    var calculation;
    calculation = 500;
    calculation+=(this.a1 = 2) ? 200 : 100;
    calculation+=(this.a2 = 80) ? 50 …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

-1
推荐指数
1
解决办法
543
查看次数

标签 统计

javascript ×2

jquery ×2

datetime ×1

html ×1

object ×1