在一个html中加入一段JS,判断其中某个单元格的值是否大于某个金额,这段JS怎么写?

解决方案 »

  1.   

    通过document.getElementById或其他方法获得这个单元格的值,然后和预期的值比较啊
    不明白楼主的意思啊
      

  2.   

    给单元格赋个ID,在根据ID来获取单元格的值 不就行了嘛
      

  3.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head>
    <script>
    function kkk(num){
    var numa = parseInt(document.getElementById("k1").innerHTML)
    alert(numa)
    if(numa > num)
    alert("该单元格的金额为"+numa+"大于"+num);
    }
    </script>
     <body>
      <table border=1>
        <tr>
      <td id="k1">500</td>
      </tr>
      </table>
      <input type="text" value=10 id="num"/><input type="button" value="对比" onclick="kkk(num.value)"/>
     </body>
    </html>