我写了如下的代码
是当鼠标点击第一个按钮时获取输入框中的内容并赋给第一个DIV。然后点击第二个按钮时将第一个DIV获取到的值赋给第二个DIV;但是我想将输入框中的一组运算结果输出到第一个DIV时,没搞明白这要怎么做。我的做法是给获取到输入框 value 用parseInt()或parseFloat()进行一次转换;但我弄出来的是NaN..求大神帮指教一下,我哪里做错了,然后应该怎么修改;谢谢哈。下面是我的代码;
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script>
window.onload = function (){
var Bat_1 = document.getElementById('Bat1');
var Bat_2 = document.getElementById('Bat2');
var Text_1 = document.getElementById('Text2');
var odiv_1 = document.getElementById('div1');
var odiv_2 = document.getElementById('div2');
Bat_1.onclick = function(){
odiv_1.innerHTML = parseFloat("Text_1.value");
}
Bat_2.onclick = function(){
odiv_2.innerHTML = odiv_1.innerHTML;
}
}
</script>
</head>
<body>
<input type="button" value="添加1" id="Bat1" onclick="Bat_zhi()" />
<input type="button" value="添加2" id="Bat2" onclick="Bat_zhi2()" />
<input type="text" value="请输入内容" id="Text2" />
<div id="div1" style="width: 200px;height: 200px;border: #089376 1px solid;float: left;"></div>
<div id="div2" style="width: 200px;height: 200px;border: #089376 1px solid;padding: 10px 10px 10px 10px;float: left;"></div>
</body>
</html>