• 会议管家——常用的JQ知识点


    一、seTimeout时间延迟

    $(".ticket_one table td a").eq(0).click(function(){
      editOd('5750339436304895721','4670593355213356731');
      setTimeout(function(){
        $("#resUser").attr("checked",false);
        $(".form-group").eq(8).find('div.col-md-9').hide();
      },300)
      return false;
    })

    二、替换标签内的某个字符

    <div class="arcCon">
    你我他多
    </div>
    $(document).ready(function() {
    //替换掉文章里的所有你并替换成哈
    var arcCon = $(".arcCon");
    arcCon.html(arcCon.html().replace(/你/ig, "哈"));
    });

    三、在某个字符后进行换行

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>中英文换行</title>
    </head>
    <body>
    <p>精忠报国Edkjf</p>
    <p>大智若愚Wwkjf</p>
    </body>
    </html>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script type="text/javascript">

    //方法一:

    var html1=$('body').html();
    html1=html1.replace('精忠报国Edkjf','精忠报国<br>Edkjf');
    html1=html1.replace('大智若愚Wwkjf','大智若愚<br>Wwkjf');
    $('body').html(html1);

    //方法二:

    $('p').eq(0).html($('p').eq(0).text().substring(0,4)+'<br>'+'Edkjf')
    $('p').eq(1).html($('p').eq(1).text().substring(0,4)+'<br>'+'Happy')

    //方法三:

    $('p').replaceWith("<div>段落<br>duanluo</div>");

    //方法四:(推荐使用,利于代码优化,不冗余)

    $('p').each(function(){
    var str=$(this).html();
    var ss=str.replace(/[^u4e00-u9fa5]/gi,'');//正则匹配到到中文字符
    var rr=str.replace(/[^x00-xff]/g,'');//正则匹配到英文字符
    $(this).html(ss+'<br>'+rr);
    })

    </script>

  • 相关阅读:
    css
    ubuntu 解压zip 文件乱码
    常用 Git 命令清单
    phpstorm git配置
    github ssh秘钥配置
    ubuntu 安装phpunit
    ubuntu 安装php xdebug
    nginx压缩,缓存
    mysql中max_allowed_packet参数的配置方法(避免大数据写入或者更新失败)
    putty登录显示IP
  • 原文地址:https://www.cnblogs.com/fkcqwq/p/9830559.html
Copyright © 2020-2023  润新知