日期:2014-05-16 浏览次数:20398 次
<input type="checkbox" onclick="chk()"/>17.77
<table id="ta">
<tr><td>8</td><td>10</td></tr>
<tr><td>9</td><td>11</td></tr>
</table>
function chk()
{
var ta=document.getElementById("ta");
var num=parseFloat(ta.rows[0].cells[1].innerHTML);//字符串转换为数字,
num=num+17.77;
ta.rows[0].cells[1].innerHTML=num;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
function show()
{
var a = document.getElementById("div1");
var b = document.getElementById("chek");
a.innerText = parseFloat(b.value) + parseFloat(a.value);
//alert(a.value);
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<input type="checkbox" id="chek" value="17.7" onclick="show()">
<table>
<tr>
<td><div id="div1" value="10">10</div></td>
</tr>
</table>
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>测试</title>
<script language="javascript">
<!--
var $ = document.getElementById;
function add(obj){
var sum = $("sum").innerText;
if(sum == "") sum=0;