" [object HTMLDivElement]"不会返回我的var

时间:2015-09-27 04:23:17

标签: javascript html css var

因此,当我运行脚本时,它会显示[object HTMLDivElement]而不是var i assign。奇怪的是,我在另一个" index.html"上做了相同的代码。它确实有效。所以我认为它是css或H​​TML中的东西,但我无法弄清楚它是什么。

编辑: 这是一个打印正在发生的事情的链接。 https://www.dropbox.com/s/1m7drbg4mzsxbtg/Screenshot%20%2815%29.png?dl=0



var timer, s, m, h;
	s = 5;
	m = 25;
	h = 11;
function timer() {
	timer = setInterval(startTimer ,1000);
}

function startTimer() {
	s++ ;
	if (s == 60) {
		s = 0;
		m++;
	}
	if (m == 60) {
		m = 0;
		h++;
	}
	document.getElementById('seconds').innerHTML = s;
	document.getElementById('minutes').innerHTML = m + ":";
	document.getElementById('hours').innerHTML = h + ":";
}

	

button {
	padding: 0;
	border: none;
	background: none;
}

#teste {
	font-size: 200;
}

#teste2 {
	font-size: 25;
}

.container {
	width: 1024px;
	height: 768px;
	background-color: yellow;
	position:relative;
	float:left;
	font-family: Courier New;
}

	.menu {
		width: 1024px;
		height: 100px;
		background-color: black; 
		position:relative;
		float:left;
}

		.despertador {
			width: 256;
			height: 100;
			background-color: gray;
			position:relative;
			float:left;
}

		.relogio {
			width: 256;
			height: 100;
			background-color: black;
			position:relative;
			float:left;
}

		.temporizador {
			width: 256;
			height: 100;
			background-color: black;
			position:relative;
			float:left;
}

		.cronometro {
			width: 256;
			height: 100;
			background-color: black;
			position:relative;
			float:left;
}
	.linha {
		width: 1024;
		height: 2px;
		background-color: white;
		position:relative;
		float:left;
	}
	
	.linha2 {
		width: 800;
		height: 1px;
		background-color: white;
		position:relative;
		float:left;
	}
	.content {
		width: 1024px;
		height: 648;
		background-color: #333333;
		position:relative;
		float:left;
}
		#despertador2 {
			width: 1024px;
			height: 648;
			background-color: #333333;
			position:relative;
			float:left;
		}
			.firstHalf {
				width: 1024;
				height: 275;
				position:relative;
				float:left;
			}
			
			.secondHalf {
				width: 1024;
				height: 374;
				position:relative;
				float:left;
			}

		
		#relogio2 {
			width: 1024px;
			height: 648;
			background-color: #333333;
			position:relative;
			float:left;
			display: none;
		}
		
		#temporizador2 {
			width: 1024px;
			height: 648;
			background-color: #333333;
			position:relative;
			float:left;
			display: none;
		}
		
		#cronometro2 {
			width: 1024px;
			height: 648;
			background-color: #333333;
			position:relative;
			float:left;
			display: none;
		}
			

<html>
	<head>
		<script src="js/menu.js"></script>
		<script src="js/relogio.js"></script>
		<link rel="stylesheet" type="text/css" href="css/estilo.css">
	</head>
	<body>
		<div class="container">
			<div class="menu">
				<div class="despertador" id="despertador">
					<button onclick="despertadorButton()"><img src="imagems/despertador1.png"  width="256" height="100"></button>
				</div>
				<div class="relogio" id="relogio">
					<button onclick="relogioButton()"><img src="imagems/relogio1.png"  width="256" height="100"></button>
				</div>
				<div class="temporizador" id="temporizador">
					<button onclick="temporizadorButton()"><img src="imagems/temporizador1.png" width="256" height="100"></button>
				</div>
				<div class="cronometro" id="cronometro">
					<button onclick="cronometroButton()"><img src="imagems/cronometro1.png" width="256" height="100"></button>
				</div>
			</div>
			<div class="linha">
			</div>
			<div class="content">
				<div Id="despertador2">
					<div class="firstHalf">
						<font id="teste">04:20</font><br>
						<font id="teste2">&nbsp;&nbsp;Quinta feira, 22 de outubro</font>
					</div>
					<div class="linha2">
					
					</div>
					<div class="secondHalf">
					
					</div>
				</div>
				<div Id="relogio2">
					<button onclick="timer()">start</button>
					<img src="imagems/circleClock.png">
					<font id="hours">Horas</font>
					<font id="minutes">Minutos</font>
					<font id="seconds">Segundos</font>
				</div>
				<div id="temporizador2">
				
				</div>
				<div Id="cronometro2">
				
				</div>
			</div>
		</div>
	</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

问题是在另一个代码中使用相同的var,我只是删除它并且它工作正常。