zoukankan      html  css  js  c++  java
  • javascript实现字符串反转

    <html>

    <head>
    <script language="javascript">
        
    function reverse()
        {
            
    var str=document.getElementById("input").value;
            
    var a=str.split('');
            
    var result=new Array();
            
    while(a.length)
            {
                result.push(a.pop());
            }
            document.getElementById(
    "result").innerHTML=result.join('');
        }
    </script>


    <title>javascript</title>

    </head>

    <body>
        
    <table>
        
    <tr>
        
    <td><input type="textfield" id="input"/>=&gt;</td>
        
    <td><div id="result"></div></td>
        
    </tr>
        
    </table>
        
    <input type="button" value="reverse" onclick="reverse()"/>
    </body>

    </html>
  • 相关阅读:
    ==和equals的区别
    Java标准库定义的常用异常
    java.lang.ArithmeticException: / by zero
    类的设计
    预处理&枚举&其他
    内存管理
    指针和字符串
    指针
    数组
    流程控制语句
  • 原文地址:https://www.cnblogs.com/xpxu/p/1683671.html
Copyright © 2011-2022 走看看