码农成长记——js(switch)

来源:互联网 发布:淘宝哪些店铺布料便宜 编辑:程序博客网 时间:2024/06/05 06:42
1. switch(表达式){                 //作用等同于if(){}else if(){}else{}
    case 值1: 结果1; break;
    case 值2: 结果2; break;
    ...
    case 值n: 结果n; break;
    default: 最终结果;
    }  //switch 语句中不加break; 所有的语句都将执行
    //break; —— 中断循环执行,在for循环中也可以使用

2. 表单
    <form name="fm1" action="news.php" method="post">//post 大数据提交
    </form>                                                              get 小数据提交,在ie地址栏可以看到
    
3. 表单元素的获取及值的获取
<input type="text" value="" id="username" class="username" placeholder="请输入用户名"/>
document.getElementByid("username").value;
eg: xx.checker = true;

4. onkeyup 键盘弹起事件

5. <form name="f2" action="news.php" method="post" onSubmit="return chk()">
    
    <input type="submit" value="提交" />
   </form>
   onSubmit = "return chk()"

6. 定义一个变量表示 true/false  或者 return true/return false

7. 要显示判断结果,必须执行判断函数,没有显示说明没有执行函数
   想要显示就在执行submit的函数里面再次执行判断的函数

8. confirm();  //确认函数
    function bb(){
        var aa = confirm("是否跳转",""); //返回bollen值 aa用来接收这个值
        if(aa){
            return ture;
        }else{return false;}
    }

9. 一个函数只能有一个返回值

10. 按钮需要接收命令

11. 全选,反选,全不选
<input type="checkbox" id="ck" /><label for="ck">全选</label>
真变假,假变真,取个反就OK
follow me

12. .buttonAlign input{vertical-align:middle; margin-bottom:2px; *margin-bottom:2px;}
    使input元素与文字对齐

13. innerHTML HTML 要大写

14. textarea开始结束标签要写在一起不然会有空格

15. input是行内块元素,一个元素设置top和left的margin值时,元素本身会偏移,而设置right和bottom的margin值时,受其影响的相邻元素会偏移。

16. 记住在 script中事件触发函数时,函数加了括号的话,页面加载后就执行了

0 0
原创粉丝点击