欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js html實(shí)現(xiàn)計(jì)算器功能

 更新時(shí)間:2018年11月13日 17:01:44   作者:~李疆  
這篇文章主要為大家詳細(xì)介紹了js html實(shí)現(xiàn)計(jì)算器功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了html實(shí)現(xiàn)計(jì)算器功能的具體代碼,供大家參考,具體內(nèi)容如下

代碼:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <title></title>
  <script type="text/javascript">
 
    var numresult;
    var str;
    function onclicknum(nums)
    {
      str = document.getElementById("nummessege");
      str.value = str.value + nums;
    }
    function onclickclear()
    {
      str = document.getElementById("nummessege");
      str.value = "";
    }
    function onclickresult()
    {
      str = document.getElementById("nummessege");
      numresult = eval(str.value);
      str.value = numresult;
    }
  </script>
 
</head>
<body bgcolor="affff">
  <!--定義按鍵表格,每個(gè)按鍵對應(yīng)一個(gè)事件觸發(fā)-->
  <table border="1" align="center" bgColor="#bbff77"
      style="height: 350px; width: 270px">
    <tr>
      <td colspan="4">
        <input type="text" id="nummessege"
            style="height: 90px; width: 350px; font-size: 50px" />
      </td>
    </tr>
    <tr>
      <td>
        <input type="button" value="1" id="1" onclick="onclicknum(1)"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="2" id="2" onclick="onclicknum(2)"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="3" id="3" onclick="onclicknum(3)"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="+" id="add" onclick="onclicknum('+')"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
    </tr>
    <tr>
      <td>
        <input type="button" value="4" id="4" onclick="onclicknum(4)"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="5" id="5" onclick="onclicknum(5)"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="6" id="6" onclick="onclicknum(6)"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="-" id="sub" onclick="onclicknum('-')"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
    </tr>
    <tr>
      <td>
        <input type="button" value="7" id="7" onclick="onclicknum(7)"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="8" id="8" onclick="onclicknum(8)"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="9" id="9" onclick="onclicknum(9)"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="*" id="mul" onclick="onclicknum('*')"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <input type="button" value="0" id="0" onclick="onclicknum(0)"
            style="height: 70px; width: 190px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="." id="point" onclick="onclicknum('.')"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
      <td>
        <input type="button" value="/" id="division"
            onclick="onclicknum('/')"
            style="height: 70px; width: 90px; font-size: 35px">
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <input type="button" value="Del" id="clear"
            onclick="onclickclear()"
            style="height: 70px; width: 190px; font-size: 35px" />
      </td>
      <td colspan="2">
        <input type="button" value="=" id="result"
            onclick="onclickresult()"
            style="height: 70px; width: 190px; font-size: 35px" />
      </td>
    </tr>
  </table>
</body>
</html>

效果圖

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • JS實(shí)現(xiàn)電子時(shí)鐘入門操作

    JS實(shí)現(xiàn)電子時(shí)鐘入門操作

    這篇文章主要為大家詳細(xì)介紹了JS實(shí)現(xiàn)電子時(shí)鐘入門操作,實(shí)現(xiàn)帶有表盤的時(shí)鐘,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • 深入淺析ES6 Class 中的 super 關(guān)鍵字

    深入淺析ES6 Class 中的 super 關(guān)鍵字

    本文給大家收藏整理了ES6 Class 中的 super 關(guān)鍵字,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧
    2017-10-10
  • 在標(biāo)題欄顯示新消息提示,很多公司項(xiàng)目中用到這個(gè)方法

    在標(biāo)題欄顯示新消息提示,很多公司項(xiàng)目中用到這個(gè)方法

    在標(biāo)題欄顯示新消息提示,很多公司項(xiàng)目中用到這個(gè)方法,需要的朋友可以參考下。
    2011-11-11
  • javascript操作select元素實(shí)例分析

    javascript操作select元素實(shí)例分析

    這篇文章主要介紹了javascript操作select元素的方法,可實(shí)現(xiàn)針對select元素選中元素時(shí)動(dòng)態(tài)改變html元素的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-03-03
  • JavaScript-RegExp對象只能使用一次問題解決方法

    JavaScript-RegExp對象只能使用一次問題解決方法

    RegExp對象執(zhí)行了一次后就廢掉了,所以每次用RegExp都需要重新new一個(gè),下面有個(gè)示例,需要的朋友可以參考下
    2014-06-06
  • 使用Nest.js實(shí)現(xiàn)接口教程示例

    使用Nest.js實(shí)現(xiàn)接口教程示例

    這篇文章主要為大家介紹了使用Nest.js實(shí)現(xiàn)接口教程示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-10-10
  • js canvas實(shí)現(xiàn)放大鏡查看圖片功能

    js canvas實(shí)現(xiàn)放大鏡查看圖片功能

    這篇文章主要為大家詳細(xì)介紹了js canvas實(shí)現(xiàn)放大鏡查看圖片功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • JavaScript中九種常用排序算法

    JavaScript中九種常用排序算法

    不同的排序算法,執(zhí)行效率有著天壤之別,本腳本用JavaScript演示了各種常見的排序算法,包括:冒泡排序、選擇排序、插入排序、謝爾排序、快速排序(遞歸)、快速排序(堆棧)、歸并排序、堆排序
    2014-09-09
  • 淺析JavaScript 調(diào)試方法和技巧

    淺析JavaScript 調(diào)試方法和技巧

    本文給大家淺析javascript調(diào)試方法和技巧,涉及到j(luò)avascript調(diào)試方法和技巧方面的知識(shí),本文介紹的非常詳細(xì),非常具有參考借鑒介紹,感興趣的朋友一起看看吧
    2015-10-10
  • CSS+Js遮罩效果的TAB及焦點(diǎn)圖片切換(推薦)

    CSS+Js遮罩效果的TAB及焦點(diǎn)圖片切換(推薦)

    CSS+Js圖片切換技術(shù),類似的已有不少了,這一個(gè)使用了遮罩過渡的效果,同樣應(yīng)用到了TAB選項(xiàng)卡上,本頁面僅是為了演示,大家用時(shí)候把它拆分開來,這個(gè)效果也對學(xué)習(xí)圖片效果制作很有幫助。
    2009-11-11

最新評論