2016年9月份工作知识点汇总

本文介绍了前端开发中的一些实用技巧,包括使用jQuery简化DOM操作及事件处理,利用CSS冻结textarea尺寸,以及通过JavaScript验证金额输入格式等。

360网站卫士常用前端公共库CDN服务

网址:http://libs.useso.com/

包括:常用前端公共库、google公共库、google字体库。


Jquery知识点1

在拼接html元素的同时,实现事件的绑定。

function createBtn(opType,id,status,ob){
    var str = '';
    if(opType==0){ //首次开通
        if(status==0){ //审核
            str = '<span onclick="firstAuditCard('+id+')" class="ib tc hand audbtn" >审核</span>';
        }else if(status==1||status==2){ //显示
            str = $('<span  class="ofblue hand">详情</span>').click(function(){
                firstCardInfo(ob);
            });
        }
    }else if(opType==1){ //再次修改
        if(status==0){ //审核
            str =  $('<span  class="ib tc hand audbtn" >审核</span>').click(function(){
                modifyAuditCard(ob);
            });
        }else if(status==1||status==2){ //显示
            str =  $('<span class="ofblue hand">详情</span>').click(function(){
                modifyCardInfo(ob);
            });
        }
    }
    return str;
}


CSS知识点1

textarea的输入内容区域尺寸冻结,不可变更

textarea {
  resize : none;
}

Javascript知识点1

javascript传入当前元素对象作为参数,即this的用法:onblur="amountCheck(this);"

function amountCheck(ob){
    var amount = ob.value;
    if(amount==""){
        return true;
    }
    if(/\s/.test(amount)){
        $.like.alert_Msg("金额不能包含空格", 0, '');
        return false;
    }
    var reg = /^[1-9]\d*|0$/;
    if(reg.test(amount)==false){
        $.like.alert_Msg("金额格式不正确", 0, '');
        return false;
    }
    return true;
}

转载于:https://www.cnblogs.com/archermeng/p/7537200.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值