tips

字符串截取前10位

let Str="2020-03-04T00:00:00"
Str.substr(0, 10)

返回上一页,同时刷新页面

<button type="button" class="btn btn-basic back pull-right"
                              onClick="javascript:window.location.replace(document.referrer);">返回</button>

 

滚动条样式

/* 滚动条样式 */
.container-widget::-webkit-scrollbar {
    /*滚动条整体样式*/
    width : 10px;  /*高宽分别对应横竖滚动条的尺寸*/
    height: 1px;
    }
.container-widget::-webkit-scrollbar-thumb {
    /*滚动条里面小方块*/
    border-radius   : 10px;
    background-color: skyblue;
    background-image: -webkit-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
);
}
.container-widget::-webkit-scrollbar-track {
    /*滚动条里面轨道*/
    box-shadow   : inset 0 0 5px rgba(0, 0, 0, 0.2);
    background   : #ededed;
    border-radius: 10px;
}

浏览器可视化宽高

    var Dwidth = $(window).width();
    var Dheight = $(window).height();
    $('.container-widget').css('height', Dheight - 132 + 'px');
    $('.container-widget').css('overflow', 'scroll');
    $('.container-widget').css('width', Dwidth - 275 + 'px');
    $('.container-widget').css('overflow', 'scroll');


    window.onresize = function () {
        var Dheight = $(window).height();
        var Dwidth = $(window).width();
        $('.container-widget').css('height', Dheight - 132 + 'px');
        $('.container-widget').css('overflow', 'scroll');
        $('.container-widget').css('width', Dwidth - 275 + 'px');
        $('.container-widget').css('overflow', 'scroll');
    }

浏览器文档可视内容宽高

    var Dwidth = $(document).width();
    var Dheight = $(document).height();
    $('.container-widget').css('height', Dheight - 132 + 'px');
    $('.container-widget').css('overflow', 'scroll');
    $('.container-widget').css('width', Dwidth - 275 + 'px');
    $('.container-widget').css('overflow', 'scroll');


    window.onresize = function () {
        var Dheight = $(document).height();
        var Dwidth = $(document).width();
        $('.container-widget').css('height', Dheight - 132 + 'px');
        $('.container-widget').css('overflow', 'scroll');
        $('.container-widget').css('width', Dwidth - 275 + 'px');
        $('.container-widget').css('overflow', 'scroll');
    }

 

限制输入50个字符 

        $(".text-count").text(50 - $(".area").val().length);
        $(".area").on("input propertychange", function() {
            var $this = $(this),
                _val = $this.val(),
                count = "";
            if (_val.length > 50) {
                $this.val(_val.substring(0, 50));
            }
            count = 50 - $this.val().length;
            $(".text-count").text(count);
        });
<div class="control-group">
	<label class="control-label">备注</label>
		<div class="controls">
			<textarea name="remark" class="medium m-wrap bookRemark area" rows="3" placeholder="不超过50字" onkeypress="showKeyPress()">{{ User.Remark}}</textarea>
             <p><span class="text-count">50</span>/50</p>
		</div>
</div>

所有为None的值设置为空值 

    var inputs=$('input')
    inputs.each(function(){
        if($(this).val()=='None'){
            $(this).val("")
        }
    });

 

 

radio设置初始值 

//radio设置初始值
$("input[name='sex'][value='"+result.user_info[0].Sex+"']").attr('checked', 'true');
// $("input[name='sex']:checked").val(result.user_info[0].Sex);//不生效

 

刷新页面

window.location.reload();

 

 

swalalert 保存成功,一秒后刷新页面

setTimeout(function(){swal("保存成功","保存","success"); },100);
setTimeout(function(){location.reload(); },1100);

打开pdf隐藏工具栏
window.open(PathApproval+'#toolbar=0&navpanes=0&scrollbar=0')

 

保留两位小数的百分比

 

var ratePass=Math.round(pass/(un+pass)*10000)/100.00+'%'
var rateUnpass=Math.round(un/(un+pass)*10000)/100.00+'%'

表格搜索

$('#myinput').on( 'keyup',function (){
      var search=this.value
      $('.abc tbody tr').hide().filter(':contains('+search+')').show();

});

对应元素打开,其他元素关闭(再次点击当前已打开元素,关闭)

var IFOnclick=$(that).children('div').attr('class');
if(IFOnclick.indexOf('active')>=0){
       $('.Doctor .lookPDF div').removeClass('active')
} else {
     $('.Doctor .lookPDF div').removeClass('active');
     $(that).children('div').addClass('active')
  }

对应元素打开关闭(其他元素独立)

$(this).parent('.lookPDF').children('div').toggleClass('active')

上传附件(火狐点击无反应)

更改后代码

<div  type="button" class="btn green start "  style="display:inline-block;position:relative;overflow: hidden;vertical-align:middle">
      <i class="icon-upload icon-white"></i>
      <span>添加数据包</span>
      <input type="file" multiple="" id="stubag" style="position:absolute;top:0;left:0;font-size:34px; opacity:0">
</div>

解决办法:由于button有默认事件,将button换成div即可调出上传附件的窗口

 

关闭浏览器,清除缓存(由于刷新也清了,暂时未使用)

window.onbeforeunload=function(){
	  //你想干的事,比如删localStorage
	  window.localStorage.clear();

	  return "真的要关掉页面吗"; 
	  //这一句如果写了,会弹窗提示是否要关掉页面,如果没这个需求,可以不写
	};

rufus  u盘启动盘

 

var reviewUn='{{ unfin_name | safe}}'

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值