JS 工作日常整理

/**点击删除*/
btn_delete : function() {                //因为是动态添加,所以该方法要在动态添加  html 的代码之后调用。每添加一次便为其绑定一次点击删除父标签的事件。
         $('.deleteImg').each(function(){    //因为多个 img 的 class 为 deleteImg,所以 $('.deleteImg')是一个数组,需要用 .each 方法遍历
           var that = this;                //that 是一个对象,$(that)是一个元素,.parent() 是一个方法。
            $(that).click(function() {
            $(that).parent().remove();
              });
          })
},

            
// 删除图片
$("#addUploadImg").on('click', 'img.deleteImg', function() {//因为是动态添加,所以要让其父类代理 为其绑定 点击删除父标签的方法。 
        $(this).parent().remove();
        $('#uploadBtn').css('pointer-events', 'initial');
});


//点击小图变大图
$('#addUploadImg').on('click','div',function(){
        layer.photos({
             photos: '.layer-photos-demo',
             anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
         });
});

// 初始化layer相册层
    var item = $('#addUploadImg').find('.uploadImg');    //由于初始化后需要点击两次才能触发点击事件,所以要在动态添加  html 的代码之后让其自动触发一次点击事件。
          if(item.length>0){
                item.eq(0).click();
        }
        
因为上面 layer.photos 方法使用代理为动态添加的html绑定,而 layer.photos 本身就使用了代理的方法。
所以建议直接在动态添加  html 的代码之后调用 :
    layer.photos({
             photos: '.layer-photos-demo',
             anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
         });


//限制图片上传次数
                                 if ($(".uploadImg").length >= 6) {
                                     $('#uploadBtn').css('pointer-events', 'none');
                                     layer.msg('只可上传六张图片文件!');
                                         layer.close(index);
                                 }


                        /*$('#bannerList').html(html);
                        var mySwiper = new Swiper('.swiper-container',{
//                            autoplay : 4000,//可选选项,自动滑动
                            loop : true,//可选选项,开启循环
                            pagination:".pagination",
                             paginationClickable:true,//实现小圆点点击
                             autoplayDisableOnInteraction:false,//在点击之后可以继续实现轮播
                             mousewheelControl : true,//能使用鼠标滚轮控制slide滑动。
                        });*/

var a = "abc";
!a = false;
!!a = true;
类似于 Boolean(a);

Number(10).toFixed(2); // 10.00

转载于:https://my.oschina.net/u/3387637/blog/1532339

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值