• JS备忘


    最近在写公司的打卡考勤系统,需要用到js,由于没有系统学过,碰到新的知识点就记下来,以便复盘。


    $("tr[id^='code']");//id属性以code开始的所有input标签

    $("tr[id$='code']");//id属性以code结束的所有input标签

    $("tr[id*='code']");//id属性包含code的所有input标签

    可以联想到正则表达式也有^开头,$结尾,^就是以什么开头的意思,$以什么结尾。


    html向js方法传递参数:

    方法一:这个方法ie可行,其他浏览器没有响应。

    <html>
        <head>
            <title> New Document </title>
            <script>
                function func(dd){
                    alert(dd);
                }
                function fun(pp){
                    alert(pp);
                }
            </script>
        </head> 
      <body>
          <input type="text" name="ddd">  
          <input type="button" value="submit" onclick="func(ddd.value)">
          <input type="text" name="pp"  onblur="fun(pp.value)">
      </body>
    </html>

    方法二:用event方式/对象传递

    <html>
        <head>
        <script>
            function bbb(event){
            event = window.event || event;
            var srcEle = event.target || event.srcElement;
            alert(srcEle.value);
          }
            
            function ccc(cc){
                alert(cc.value);
            } 
        </script>
        </head>
        <body>
            <input type="text" value="by event"  οnblur="bbb()"/> 
            <input type="text" value="by object"  οnblur="ccc(this)"/>
        </body>
    </html>

    js点击事件总报错onclick is not defined错误


    1

    1

  • 相关阅读:
    css实现垂直居中
    js验证输入框
    textarea统计字数
    ajax提交form表单
    JS中的正则表达式
    《遮蔽层的隐藏块》
    2016各大互联网公司前端面试题汇总
    JQ 添加节点和插入节点的方法总结
    [原]CentOS7部署osm2pgsql
    [原]CentOS7部署PostGis
  • 原文地址:https://www.cnblogs.com/jszfy/p/11150597.html
Copyright © 2020-2023  润新知