模态框中加入 data-backdrop=”static” 属性<div class="modal fade examplemodal" tabindex="-1" aria-labelledby="mySmallModalLabel" aria-hidden="true" data-backdrop="static"></div>

前端 2018-12-04

根据时间戳及想要的时间格式装换出时间的js函数使用效果date("Y-m-d",1543920494) 2018-12-04 date("Y-m-d H:i:s",1543920494) 2018-12-04 18:48:14功能代码function date(format, timestamp) { var a, jsdate = ((timestamp) ? new Date(timestamp * 1000) : new Date()); var pad = function (n, c) { if ((n = n + "").length < c) { return new Array(++c - n.length).join("0") + n; } else { return n; } };

前端 2018-12-04

在Bootstrap model弹出层上面使用layer prompt,input框无法获取焦点。解决方案:去除tabindex属性<div class="modal fade" id="template-modal" tabindex="-1" role="dialog" aria-hidden="true">

前端 2018-11-09

按钮<a data-toggle="modal" data-target=".detail" data-id="999" title="详细资料"><i class="ti-user"></i></a>获取参数$('.detail').on('show.bs.modal', function (e) { var btn = $(e.relatedTarget); var id = btn[0].dataset.id; })

前端 2018-10-11

假设cookie中存储的内容为:name=jack;password=123则在页面中获取变量username的值的JS代码如下:var username=document.cookie.split(";")[0].split("=")[1]; //JS操作cookies方法! //写cookies function setCookie(name,value) { var Days = 30; var exp = new Date(); exp.setTime(exp.getTime() + Days*24*60*60*1000); document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); }读取cookiesfunction getCookie(name) { var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");

前端 2018-09-06

html demo<div id="headerMenu"> <ul> <li> <a href="/"> 首页</a> </li> <li> <a href="/info"> 信息</a> </li> </ul> </div>jqueryvar CURRENT_URL = window.location.href.split('#')[0].split('?')[0]; var SIDEBAR_MENU = $('#headerMenu'); // check active menu SIDEBAR_MENU.find('a[href="' + CURRENT_URL

前端 2018-09-05

谷歌浏览器默认禁用了flash插件,所以要判断下浏览器是否禁用了flashfunction flashJudge(){ var flag = false; if(window.ActiveXObject){ try{ var swf = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); if(swf){ flag = true; } }catch(e){ } }else{ try{ var swf = navigator.plugins['Shockwave Flash']; if(swf){ flag = true; } }catch(e){ } } if(flag){

前端 2018-07-24

丢弃小数部分,保留整数部分parseInt(5/2) ```` 向上取整,有小数就整数部分加1 ====Math.ceil(5/2) 四舍五入 ==== ```javascript Math.round(5/2)向下取整Math.floor(5/2)

前端 2018-07-23

html demo<input id="checkboxID" type="checkbox" value="imxgr" />javascript写法if(document.getElementById("checkboxID").checked){ alert("checkbox is checked"); }jquery写法$("input[type='checkbox']").attr('value') 返回结果:imxgr $("input[type='checkbox']").is(':checked') 返回结果:选中=true,未选中=false

前端 2018-07-20

javascript写法获取值var obj = document.getElementById("testSelect"); //定位id var index = obj.selectedIndex; // 选中索引 var text = obj.options[index].text; // 选中文本 var value = obj.options[index].value; // 选中值jquery写法获取值$('#testSelect option:selected').text();//选中的文本 $('#testSelect option:selected') .val();//选中的值 $("#testSelect ").get(0).selectedIndex;//索引 或 $("#tesetSelect").find("option:selected").text();//选中的文本 $("#tesetSelect").find(

前端 2018-07-20