JavaScript代码笔记重点:

JavaScript的基本特点:JavaScript是基本对象和事件驱动,具有实时性,动态性,跨平台性和安全性等。
JavaScript是对大小写敏感的。

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    var num = Number(prompt("请输入一个0-100之间的数字",""));
    if(isNaN(num)){
    document.write("你输入的不是数字,请确认你的输入。");
}else if(num>0 || num<100){
    document.write("你输入的数字范围不在0-100之间。");
}else{
    document.write("你输入的数字是:"+num);
}
</body>
</html>
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <script type="text/javascript">
        document.write("<center>");
        var row = parseInt(prompt("请输入打印的行数",""));
        for(var i=0;i<row;i++){
            for(var j=0;j<=i;j++){
                document.write(" * ");
            }
            document.write("<br/>");
        }
        document.write("</center>");
    </script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <tr>
        <td><input name="addButton2" type="button" id="addBtn" value="+"></td>
        <td><input name="subButton2" type="button" id="subBtn" value="-"></td>
        <td><input name="mulButton2" type="button" id="mulBtn" value="*"></td>
        <td><input name="divButton2" type="button" id="divBtn" value="/"></td>
    </tr>
    <<tr>
        <td>计算机结果</td>
        <td colspan="3"><input name="txtresult" type="text" id="txtresult" size="25"/></td>
    </tr>
    <script type="text/javascript">
        function compute(obj){
            var num1,num2,result;
            num1 = parseFloat(document.myform.txtNum1.value);
            num2 = parseFloat(document.myform.txtNum2.value);
            switch(obj){
                case"+":
                result=num1+num2;
                case"-":
                result=num1-num2;
                case"*":
                result=num1*num2;
                case"/":
                if (num2!=0) {
                    result=num1/num2;
                }else{
                    result="除数不能为0,请重新输入!";
                }
            }
        }
    </script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
    <title>选号题</title>
    <style type="text/css">
        .inputTxt{
            height: 500px;
            width: 600px;
            font-size: 360px;
            text-align: center;
        }
    </style>
    <script type="text/javascript">
        var timer;
        function startScroll(){
            var num = Math.floor(Math.random()*60+1);
            document.myFrom.value=num;
            timer = setTimeout("startScroll()",60);
        }
        function stopScroll(){
            clearTimeout(timer);
        }
    </script>
</head>
<body>
    <center>
        <form name="myFrom">
        <input name="myText" type="text" value="0" class="inputTxt"/>
        <input name="start" type="button" value="开始" onclick="startScroll()"/>
        <input name="stop" type="button" value="停止" onclick="stopScroll()"/>
        </form>
    </center>

</body>
</html>

关注我,每天都有优质技术文章推送。工作,学习累了的时候放松一下自己。

本文如果对你有帮助请点顶你的顶是对我最大的肯定!!!

posted @ 2017-10-28 15:59  达达前端  阅读(134)  评论(0编辑  收藏  举报