• JS对象:Number、String


    JavaScript中的对象是有着属性和方法的一种特殊数据类型。 

    常见的对象有数字Number,字符串String,日期Date,数组Array等。 

    Number

    练习

    <style>
    input{
        50px;
    }
    </style>
    
    <script>
    function calc(){
        var n1=document.getElementById("num1").value;
        var n2=document.getElementById("num2").value;
        n1=parseFloat(n1);
        n2=parseFloat(n2);
        var n3=n1*n2;
        var num=new Number(n3);
        document.getElementById("res").value=num.toExponential();
    }
    </script>
    
    <body>
    <input type="text" id="num1" value="5">*
    <input type="text" id="num2" value="6">=
    <input type="text" id="res">
    <input type="button" value="运算" onclick="calc()">
    </body>

    String

    练习

    <script>
    function getValue(id){
       return document.getElementById(id).value;
    }
    function setValue(id,value){
       document.getElementById(id).value=value;
    }
    function replace(){
     
      var src = getValue("src")
     
      var search = getValue("search")
      var replace = getValue("replace")
      var regS = new RegExp(search,"g");
      var result = src.replace(regS, replace);
      setValue("result",result);
    }
     
    </script>
    <table>
    <tr>
      <td>源字符串:</td>
      <td><textarea id="src">example</textarea></td>
    </tr>
    <tr>
      <td>查询:</td>
      <td><input type="text"  id="search" value="a" ></td>
    </tr>
    <tr>
      <td>替换为:</td>
      <td><input type="text"  id="replace" value="e" ></td>
    </tr>
    <tr>
      <td>替换结果:</td>
      <td><textarea id="result"></textarea></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><button onclick="replace()">替换</button></td>
      <td></td>
    </tr>
    </table>
  • 相关阅读:
    ABAP TCode
    SAP 常用的事务代码
    SAP FI TCode
    Little Tutorials的一篇文章断言:UML(统一建模语言)正在死亡:
    SAP PP TCode
    [ZT]解密中国IT人十大职业现状
    User Exit Query
    SAP客户端多语言设置
    一个女CIO的诞生
    DIY防奸手册之 主流硬盘型号解惑篇
  • 原文地址:https://www.cnblogs.com/exciting/p/10639311.html
Copyright © 2020-2023  润新知