我的简便代码

*{margin: 0;padding: 0;word-wrap: break-word;}
body{background:#fff;color: #333333;font-size: 15px;line-height: 24px;margin:0 auto;position: relative;text-rendering:optimizelegibility;top: 0;font-family:Hiragino Sans GB,Lantinghei SC,华文细黑,STHeiti,微软雅黑,Microsoft YaHei,SimHei,Helvetica Neue,Helvetica,Arial,sans-serif;}
img {border: medium none;margin: 0px auto; width: auto; max-width: 100%; padding: 0px;vertical-align:middle;}
ul, ol, li {list-style: none outside none;font-size: 100%;vertical-align: baseline;}
a{ text-decoration:none;color: #333333;outline: none}
table{width:100%; text-align: center;border-collapse:collapse;border-spacing:0; }
table td{ border: 1px solid #CCCCCC;}
input[type=number],input[type=text],input[type=tel],input[type=datetime],input[type=button],select,textarea{font-family:"微软雅黑","arial","calibri"; font-size: 16px; border:none; background:transparent; width:100%; -webkit-appearance: none;outline:none;}
.clear:after{content:"."; display:block;height:0;clear:both;visibility:hidden;}
select{appearance:none;
-moz-appearance:none;
-webkit-appearance:none;
}
select::-ms-expand { display: none; }

 

css3元素居中:left:50%;top: 50%;-webkit-transform: translate(-50%,-50%);
文字垂直居中:text-align:justify;text-justify:inter-ideograph
取消点击边框:-webkit-tap-highlight-color:rgba(0,0,0,0);
css3序号:
ul{ counter-reset:sectioncounter;}
ul li:before {
content:counter(sectioncounter) " " ;
counter-increment:sectioncounter;
}
css3尖角:
.kele{ position: relative; width: 40px; height: 28px; background: #EEE; border-radius: 5px; margin: 30px; text-align: center; line-height: 28px; color: #999; font-size: 14px; border: 1px solid #CCC; }
.kele:after{ position: absolute; content: " "; border: transparent 13px solid; border-width: 12px 8px; border-right-color: #EEE; top: 2px; left: -15px; height: 0; width: 0; }

y轴滚动:overflow-y: scroll;

php日期输出:<?php echo date('Y年m月d日'); ?>

js 跳转链接:onclick="location.href='2.html'" 或者 onClick="window.location.href='1.html'"
返回上一页:<a href="javascript:void(0);" onClick="javascript:history.back(-1);">返回</a>
微信关闭当前页:onclick="WeixinJSBridge.call('closeWindow');"
刷新页面:onclick="window.location.reload();"
返回随机整数:return x1 + Math.floor(Math.random() * (x2 - x1 + 1));


头文信息:
<meta content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<meta name="viewport" content="width=320px" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

meta跳转:<meta http-equiv="refresh" content="0;url=http://www.jb51.net">

禁打电话:<meta name="format-detection" content="telephone=no" />
禁止链接高亮:-webkit-tap-highlight-color:rgba(0,0,0,0);
禁止链接长按弹出选项菜单:-webkit-touch-callout:none;

嵌入字体:
@font-face {font-family: "幼圆"; src: url("fonts/幼圆.ttf") format("truetype");}


IE兼容 background-size css代码:
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
src='img/1.jpg',
sizingMethod='scale');


jq库:<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js

http://cdn.bootcss.com/respond.js/1.4.2/respond.js

边框合并:table { border-collapse: collapse; }

自动换行:word-break:break-all;word-wrap:break-word;white-space:normal;

文本溢出显示省略符:text-overflow: ellipsis;overflow:hidden;white-space:nowrap;
段落省略符:
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;

清除浮动:.clear:after{content:"."; display:block;height:0px;clear:both;visibility:hidden;}

三角形:height:0; width:0; border-width:20px 20px 20px 0; border-color: transparent #09F; border-style:solid;
三角形线框:
<div class="sorts-ele-dropdown"><div class="sorts-ele-dropdownin"></div></div>
.sorts-ele-dropdown{position: absolute; left: 50%; top: -20px; transform: translate(-50%,0); height:0; width:0;
border-width: 0 20px 20px 20px; border-color:#EEEEEE transparent ; border-style:solid;}
.sorts-ele-dropdownin{position: absolute; left:0; top: 1px; transform: translate(-50%,0); height:0; width:0;
border-width: 0 19px 20px 19px; border-color: #fff transparent; border-style:solid;}

 

if ($(e.target).is('.face-dropdown, .face-dropdown *,.facebtn, .facebtn *'))return;

css hack兼容IE写法:
“-″减号是IE6专有的hack
“\9″ IE6/IE7/IE8/IE9/IE10都生效
“\0″ IE8/IE9/IE10都生效,是IE8/9/10的hack
“\9\0″ 只对IE9/IE10生效,是IE9/10的hack
示例:_color:red;color:red\0;color:red\9\0;

滚动条css3样式:
::-webkit-scrollbar {
width:10px;
}
/*轨道*/
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(88,88,88,0.6);
-webkit-border-radius: 10px;
border-radius: 10px;cursor: pointer;
}
/* 滑块 */
::-webkit-scrollbar-thumb {
-webkit-border-radius: 10px;
border-radius: 10px;
background:rgba(129, 129, 129,0.5);
-webkit-box-shadow: inset 0 0 4px rgba(0,0,0,0.2);
cursor: pointer;
}
/*焦点不在滑块上 */
::-webkit-scrollbar-thumb:window-inactive {
background: rgba(93,93,93,0.4);
}


手机滑动属性:
-webkit-overflow-scrolling: touch;

css3弹性模型(垂直居中)
父元素:display:-webkit-box;vertical-align: middle;-webkit-box-orient: vertical;-webkit-box-pack: center;-webkit-box-align: center;

css3固定宽度文字两端对齐:
text-align: justify;
text-justify: distribute-all-lines;
text-align-last: justify;

css3选择器:div[class^="split"]


li:nth-child(1)

Jquery伸缩:
<script>
$(document).ready(function(){
$(".check").click(function(){
$('.menu').slideToggle(0);
});
});
</script>

设置表单非空提示:
<script type="text/javascript">

$(function () {

$("input")
.bind("focus", function () {

$("div").html("请输入您的姓名!");

})

$("input").bind("blur", function () {

if ($(this).val().length == 0)

$("div").html("你的名称不能为空!");

})

});

</script>

改变下拉选择框显示:
<script type="text/javascript">

$(function () {

$("select").bind("change", function () {

if ($(this).val() == "苹果")

$(this).css("background-color", "red");

else

$(this).css("background-color", "green");

})

});

</script>

setTimeout(function(){
$("#slider").show();
},200);


控制音乐播放jq:
var isPlay = true;
$("#play").click(function(){
$("#play").toggleClass("pause");
if (isPlay == false) {
oAudio.play();
isPlay = true;
}
else {
oAudio.pause();
isPlay = false;
}
});

防止屏幕拖动:
document.documentElement.addEventListener('touchmove', function (e) { e.preventDefault(); });


字体适应多种屏幕css:
@media screen and (min-width:240px) {
html, body{
font-size:9px;
}
}
@media screen and (min-width:320px) {
html, body{
font-size:12px;
}
}
@media screen and (min-width:480px) {
html, body{
font-size:18px;
}
}
@media screen and (min-width:640px) {
html, body{
font-size:24px;
}
}

二倍分辨率屏幕:
@media screen and (-webkit-min-device-pixel-ratio: 2),screen and (min--moz-device-pixel-ratio:2),screen and (min-device-pixel-ratio:2),screen and (min-resolution:2dppx){

}


腾讯视频播放代码:(修改vid)
<iframe width="100%" height="200" style="z-index: 1; width: 100% !important; margin: 0 auto; height: 200px !important; overflow: hidden;" allowfullscreen="" qbiframeattached="true" scrolling="no" src="http://v.qq.com/iframe/player.html?vid=e0152v0e3qx">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<title>视频</title>
<meta http-equiv="expires" content="0">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
</head>
<body>
<embed wmode="direct" flashvars="vid=e0152v0e3qx&amp;tpid=0&amp;showend=1&amp;showcfg=1&amp;searchbar=1&amp;pic=http://shp.qpic.cn/qqvideo_ori/0/e0152v0e3qx_496_280/0&amp;skin=http://imgcache.qq.com/minivideo_v1/vd/res/skins/TencentPlayerMiniSkin.swf&amp;shownext=1&amp;list=2&amp;autoplay=0"
src="http://imgcache.qq.com/tencentvideo_v1/player/TPout.swf?max_age=86400&amp;v=20140714" quality="high" name="tenvideo_flash_player_1429518195839" id="tenvideo_flash_player_1429518195839" bgcolor="#000000" width="300px" height="200px" align="middle"
allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" pluginspage="http://get.adobe.com/cn/flashplayer/">
</body>
</html>
</iframe>


计时js代码:
<script type="text/javascript">

var t;

var sec=0;

function timedCount()

{

document.getElementById('timer').innerHTML=sec+" 秒 " ;

sec=sec+1 ;

t=setTimeout("timedCount()",1000) ;


}

function stopCount()

{

clearTimeout(t) ;

}

</script>


根据年月获取当月天数:
function getDaysInMonth(year,month){
month = parseInt(month,10);
//parseInt(number,type)这个函数后面如果不跟第2个参数来表示进制的话,默认是10进制。
var temp = new Date(year,month,0);
return temp.getDate();
}


图像边框:
border-image:url(img/hua.png)0 round ;-moz-border-image:url(img/hua.png)0 round ;-webkit-border-image:url(img/hua.png)0 round ;-o-border-image:url(img/hua.png)0 round ;
box-sizing :content-box;

渐变背景:
#f5f4df,#ecd391;#fefefe,#efefef;

灰白:
background-image:-webkit-linear-gradient(#f1f1f1,#ddd);background-image:-moz-linear-gradient(#f1f1f1,#ddd);background-image:-ms-linear-gradient(#f1f1f1,#ddd);background-image:-o-linear-gradient(#f1f1f1,#ddd);background-image:linear-radient(#f1f1f1,#ddd);

火红:
background-image:-webkit-linear-gradient(#f3614e,#e81717);background-image:-moz-linear-gradient(#f3614e,#e81717);background-image:-ms-linear-gradient(#f3614e,#e81717);background-image:-o-linear-gradient(#f3614e,#e81717);background-image:linear-radient(#f3614e,#e81717);


新认识的标签:<abbr> 标签表示它所包含的文本是一个更长的单词或短语的缩写形式<abbr title="People's Republic of China">PRC</abbr>。

除placeholder外,点击清空表单注释:onfocus="this.value = '';this.type = 'password';"


判断所有的input:text是否都不为空:$('form :input').each(function(){if(!$(this).val()){return false;}})

输入框默认密码两字:

方法一:<input type="text" value="密码" onfocus="if(this.value=='密码') this.value=''" onblur="if(this.value=='') this.value='密码'" />

使用方法二:<div id="pwd_warpper" style="width:150px;height:24px;">
<input type="text" value="请输入密码" id="cardpswd" onfocus="showpassword();" />
</div>

<script>
function showtext() {
if($("#password").val()=="") {
$("#pwd_warpper").html("<input type=\"text\" value=\"请输入密码\" id=\"cardpswd\" onfocus=\"showpassword();\" />");
}
}

function showpassword() {
$("#pwd_warpper").html("<input type=\"password\" value=\"\" id=\"password\" onblur=\"showtext();\" />");
/**
这里为什么要用setTimeout,因为ie比较傻,刚创建完对象,你直接设置焦点
在ie下是不会响应的,你必须留出时间给ie缓冲下,所以加上了这个定时器
**/
setTimeout(function(){
$("#password").focus();
},20);
}

$(function(){
var usernameDefStr = $("#username").val();
$("#username").focus(function(){
if($(this).val()==usernameDefStr)
$(this).val("");
});
$("#username").blur(function(){
if($(this).val()=="")
$(this).val(usernameDefStr);
});

});
</script>


经典的按钮样式:
.btnGray { background-color: #F1F1F1; background-image: -moz-linear-gradient(center bottom , #DCDADA 3%, #F9F9F9 97%, #FFFFFF 100%); border: 1px solid #AAAAAA; border-radius: 3px 3px 3px 3px; box-shadow: 0 1px 1px #AAAAAA; color: #000000; cursor: pointer; display: inline-block; font-size: 14px; line-height: 1.5; overflow: visible; padding: 5px 20px; text-align: center; vertical-align: bottom;}

.btnGray:hover { background-color: #F9F9F9; background-image: -moz-linear-gradient(center bottom , #F8F8F8 3%, #F9F9F9 97%, #FFFFFF 100%);
color: #000000;}

.btnGray:active { background: -moz-linear-gradient(center bottom , #999999 0%, #E5E5E5 3%, #CCCCCC 97%, #FFFFFF 100%) repeat scroll 0 0 #E5E5E5; color: #000000; text-decoration: none;
}

jq点击对应输出:
city.each(function(i){
$(this).click(function(){
$('#list').slideUp(0);
store.eq(i).show();
});
});

var td=$("#choose tr td");
td.click(function(){
$("#js_baozang").show();
var n=td.index(this)+1;
for(i=1;i<td.length+1;i++){
td.eq(i-1).find(".bzbtn").removeClass("b"+i+"sel").addClass("b"+i);
};
$(this).find(".bzbtn").removeClass("b"+n).addClass("b"+n+"sel");

});


页面自动刷新js版
<script language="JavaScript">
function myrefresh()
{ window.location.reload();}
setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>

页面自动跳转
<meta http-equiv="refresh" content="20;url=http://www.javaeye.com">
其中20指隔20秒后跳转到http://www.javaeye.com页面


//1.js验证只能输入数字.
function check_validate1(value){
//定义正则表达式部分
var reg = /^\d+$/;
if( value.constructor === String ){
var re = value.match( reg );
return true;
}
return false;
}
//2.js验证只能输入字母.数字和下划线.
function check_validate2(value){
var reg = /^\w+$/;
if( value.constructor === String ){
var re = value.match( reg );
return true;
}
return false;

}
//3.js验证固定电话:只能是数字.并且有相应的格式//028-67519441 或者 0839-8777222或者 028-6545124
function check_validate(value){
var reg = /^(\d{3,4})-(\d{7,8})/;
if( value.constructor === String ){
var re = value.match( reg );
return true;
}
return false;
}


微信分享接口

<script>
/** 微信分享 **/
WeixinApi.ready(function(Api) { // 需要分享的内容,请放到ready里
var MyApi = Api;
var wxData = {// 微信分享的数据
"appId": "wx35443c289c080ebc",
"imgUrl": '<?php echo $share_img;?>',
"link": '<?php echo $share_url;?>',
"desc": "这是我的幸运之门,小伙伴们,赶紧来看看吧!",
"title": "亚航假日神秘房间"
};
if (MyApi !== "") {
MyApi.shareToFriend(wxData); // 用户点开右上角popup菜单后,点击分享给好友,会执行下面这个代码
MyApi.shareToTimeline(wxData); // 点击分享到朋友圈,会执行下面这个代码
MyApi.shareToWeibo(wxData); // 点击分享到腾讯微博,会执行下面这个代码
}
});
</script>

高和宽全屏js:
$(document).ready(function() {
var bw = document.documentElement.clientWidth;
var bh = document.documentElement.clientHeight;
$(".fullbg").css({
height: bh,
width: bw
});
});

window.screen.availWidth 返回当前屏幕宽度(空白空间)
window.screen.availHeight 返回当前屏幕高度(空白空间)
window.screen.width 返回当前屏幕宽度(分辨率值)
window.screen.height 返回当前屏幕高度(分辨率值)
window.document.body.offsetHeight; 返回当前网页高度
window.document.body.offsetWidth; 返回当前网页宽度
document.body.scrollWidth 返回页面总高


placehold换行:
textarea::-webkit-input-placeholder:after{
display:block;
content:"为家。"; /* 这里 \A 形成回车符号 */
color:red;
};

弹跳css3效果

@-webkit-keyframes jump {
0% {top: 0;-webkit-animation-timing-function: ease-in;}
40% {}
50% {top: 4px;-webkit-animation-timing-function: ease-out;}
55% {top: 10px; -webkit-animation-timing-function: ease-in;}
65% {top: 6px; -webkit-animation-timing-function: ease-out;}
95% {top: 0;-webkit-animation-timing-function: ease-in; }
100% {top: 0;-webkit-animation-timing-function: ease-in;} }

提取文件夹内的文件名:
DIR *.* /B >LIST.TXT 放进txt文件,修改后缀为bat,双击打开

遍历json对象:
var json = [{dd:'SB',AA:'东东',re1:123},{cccc:'dd',lk:'1qw'}];
for(var i=0,l=json.length;i<l;i++){
for(var key in json[i]){
alert(key+':'+json[i][key]);
}
}

$(window).height();//是文档窗口高度
$("div").offset().top//是标签距离顶部高度
$(document).scrollTop();//是滚动条高度
$("div").height();//是标签高度
你要的高度+$("div").height()+[$("div").offset().top-$(document).scrollTop()]=$(window).height();

//验证手机号码
function checkMobile(){
var sMobile = document.mobileform.mobile.value
if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(sMobile))){
alert("不是完整的11位手机号或者正确的手机号前七位");
document.mobileform.mobile.focus();
return false;
}
}

velocity动画插件:
http://julian.com/research/velocity/build/jquery.velocity.min.js
http://julian.com/research/velocity/build/velocity.ui.js


bootstrap3兼容ie8方法:
https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js
https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js

CSS3无前缀脚本prefixfree.js:
<script src="http://www.zhangxinxu.com/study/js/mini/prefixfree.min.js"></script>

iframe自适应高度:
function SetWinHeight(obj)
{
var win=obj;
if (document.getElementById)
{
if (win && !window.opera)
{
if (win.contentDocument && win.contentDocument.body.offsetHeight)
win.height = win.contentDocument.body.offsetHeight;
else if(win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight;
}
}
}
iframe调用onload="Javascript:SetWinHeight(this)"

判断浏览器类型:
function userBrowser(){
var browserName=navigator.userAgent.toLowerCase();
if(/msie/i.test(browserName) && !/opera/.test(browserName)){
alert("IE");
return ;
}else if(/firefox/i.test(browserName)){
alert("Firefox");
return ;
}else if(/chrome/i.test(browserName) && /webkit/i.test(browserName) && /mozilla/i.test(browserName)){
alert("Chrome");
return ;
}else if(/opera/i.test(browserName)){
alert("Opera");
return ;
}else if(/webkit/i.test(browserName) &&!(/chrome/i.test(browserName) && /webkit/i.test(browserName) && /mozilla/i.test(browserName))){
alert("Safari");
return ;
}else{
alert("unKnow");
}
}

 

getBoundingClientRect():这个方法返回一个矩形对象,包含四个属性:left、top、right和bottom。分别表示元素各边与页面上边和左边的距离。
var box=document.getElementById('box'); // 获取元素

alert(box.getBoundingClientRect().top); // 元素上边距离页面上边的距离

alert(box.getBoundingClientRect().right); // 元素右边距离页面左边的距离

alert(box.getBoundingClientRect().bottom); // 元素下边距离页面上边的距离

alert(box.getBoundingClientRect().left); // 元素左边距离页面左边的距离

注意:IE、Firefox3+、Opera9.5、Chrome、Safari支持,在IE中,默认坐标从(2,2)开始计算,导致最终距离比其他浏览器多出两个像素,我们需要做个兼容。


h5标签兼容ie9以下浏览器:
<!--[if lt IE9]>
<script>
(function() {
if (!
/*@cc_on!@*/
0) return;
var e = "abbr, article, aside, audio, canvas, datalist, details, dialog, eventsource, figure, footer, header, hgroup, mark, menu, meter, nav, output, progress, section, time, video".split(', ');
var i= e.length;
while (i--){
document.createElement(e[i])
}
})()
</script>
<![endif]-->

转义符:小型大与号和小与号&laquo;&raquo;

逢千位数加逗号:
function toThousands(num) {
var num = (num || 0).toString(), result = '';
while (num.length > 3) {
result = ',' + num.slice(-3) + result;
num = num.slice(0, num.length - 3);
}
if (num) { result = num + result; }
return result;
}

var n=$("#num").text();
n=toThousands(n);
$("#num").text(n);

//判断页面滚动方向
function scroll( fn ) {
var beforeScrollTop = document.body.scrollTop,
fn = fn || function() {};
window.addEventListener("scroll", function() {
var afterScrollTop = document.body.scrollTop,
delta = afterScrollTop - beforeScrollTop;
if( delta === 0 ) return false;
fn( delta > 0 ? "down" : "up" );
beforeScrollTop = afterScrollTop;
}, false);
}
scroll(function(direction) {
if(direction=="down"){
//执行的代码
}
});

数字千位加逗号精简版:
a.toLocaleString().replace(".00","");

ie8以下透明度:
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);

点击选择:
onClick="javascript:this.focus();this.select();"

ie兼容background-size:
background-image: url('http://img0.bdstatic.com/img/image/6992fdda3cc7cd98d10273a6b34233fb80e7aec90cc.jpg');
background-size: cover;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
src='http://img0.bdstatic.com/img/image/6992fdda3cc7cd98d10273a6b34233fb80e7aec90cc.jpg',sizingMethod='scale');

表单输入框模仿placehold:
<input style="color: #AAAAAA;" type="" name="" id="aa" value="默认值" />
<script>
$(function(){
$("#aa").focus(function(){
var cval = $(this).val();
$(this).css("color","#333333");
if(cval=="默认值"){
$(this).val("");
}
});
$("#aa").blur(function(){
var cval = $(this).val();
if(cval==""){
$(this).val("默认值").css("color","#AAAAAA");
}
});
});
</script>

尖括号字体:
font-family: "SimHei", "SimSun";

<link href="laodongjia/images/favicon.ico" type="image/x-icon" rel="icon">

login:
<link href="laodongjia/chat/css/login.css" rel="stylesheet">
<link href="laodngjia2/news/jin10/css/animate.css" rel="stylesheet">

 

判断ie8以下:
var isIE=!!window.ActiveXObject;
var isIE6=isIE&&!window.XMLHttpRequest;
var isIE8=isIE&&!!document.documentMode;
var isIE7=isIE&&!isIE6&&!isIE8;
if(isIE6||isIE8||isIE7){
$("#pop1").show();
}

 

 

placehold颜色:
input::-webkit-input-placeholder{color: #ffffff;}

隐藏select下拉箭头:
appearance:none;
-moz-appearance:none;
-webkit-appearance:none;
select::-ms-expand { display: none; }

input 的属性autocomplete 默认为on
其含义代表是否让浏览器自动记录之前输入的值


懒加载:
<script type="text/javascript" src="laodngjia2/jiaoyi/js/jquery.lazyload.min.js"></script>
//懒加载
$("img.lazy").lazyload({
effect : "fadeIn",
effect_speed : 500
});

谷歌输入框自动填充:
input:-webkit-autofill {-webkit-box-shadow: 0 0 0px 1000px white inset;}

字体变细:
-webkit-font-smoothing: antialiased;

js获取星期:
var time = new Date();
var week = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'][time.getDay()];
//console.log(time.getDay());
console.log('今天是'+week);

js获取当前时间:
var d=new Date(),mydate="";
mydate+= d.getFullYear()+"年";
mydate+= d.getMonth()+1+"月";
mydate+= d.getDate()+"日";
$("#nowtime").text(mydate);

日历插件:
<script src="laodngjia2/news/plugins/laydate/laydate.js"></script>
<script>
!function(){
laydate.skin('molv');//切换皮肤,请查看skins下面皮肤库
}();

var start = {
elem: "#time_start",
format: 'YYYY-MM-DD hh:mm:ss',
min: '1970-06-16', //设定最小日期为当前日期
max: '2099-06-16', //最大日期
istoday: true,
istime: true,
choose: function(datas){
end.min = datas; //开始日选好后,重置结束日的最小日期
end.start = datas //将结束日的初始值设定为开始日
}
};
var end = {
elem: "#time_end",
format: 'YYYY-MM-DD hh:mm:ss',
min: '1970-06-16',
max: '2099-06-16',
istoday: true,
istime: true,
choose: function(datas){
start.max = datas; //结束日选好后,充值开始日的最大日期
}
};
laydate(start);
laydate(end);
</script>

关闭浏览器:
window.opener=null;window.open('','_self');window.close();

判断访问终端
var browser={
versions:function(){
var u = navigator.userAgent, app = navigator.appVersion;
return {
trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部
weixin: u.indexOf('MicroMessenger') > -1, //是否微信 (2015-01-22新增)
qq: u.match(/\sQQ/i) == " qq" //是否QQ
};
}(),
language:(navigator.browserLanguage || navigator.language).toLowerCase()
}
if(browser.versions.android){
//执行
}

JSON字符串转换为JSON对象:
var obj =eval('('+ str +')');
var obj = str.parseJSON();
var obj = JSON.parse(str);

JSON对象转换为JSON字符串:
var last=obj.toJSONString();
var last=JSON.stringify(obj);

分支:
查看分支:git branch
创建分支:git branch name
切换分支:git checkout name
创建+切换分支:git checkout -b name

ajax:

$.ajax({
url: url,
method: 'get',
dataType:'jsonp',
data: {},
jsonp: 'jsonpCallback',
beforeSend: function() {

},
success: function(json) {
if(json.status == 200) {
var datas = json.data;
var len = datas.length;
var html = '';

$.each(datas, function(index, item) {
var url = datas[index].url;
html+="<a class='fancyimg' href='" + url + "'><img src='" + url + "' /></a>";
});

$("#picbox").append(html);
} else if(res.status == 404) {

}

},
error: function(e) {
console.log("加载失败");
}
});


跨域写法:
$.ajax({
url: 'http://screen.jin10.com/update_screen_version',
method: 'get',
dataType: 'jsonp',
jsonp: 'jsonpCallback',
success: function (res) {
showTips('');
}
})


<!--下雪特效-->
<div class="htmleaf-container">
<div id="divSnow-1" class="htmleaf-content "></div>
</div>
<script type="text/javascript" src="laodngjia2/news/jin10/mytest/tushuo/h5/js/Websnowjq.js"></script>
<script type="text/javascript">
$("#divSnow-1").websnowjq();
</script>

//百度分享
window._bd_share_config = {
common : {
bdText : '《金十早报》-金十数据',
bdDesc : '《金十早报》每逢周一至周五早上10:30准时开播',
bdUrl : 'http://tv.jin10.com/',
bdPic : 'laodngjia2/news/jin10/tv/img/bdshare.jpg'

},
share : [{
"bdSize" : 22
}],
image : [{
viewType : 'list',
viewPos : 'top',
viewColor : 'black',
viewSize : '22',
viewList : ['qzone','tsina','huaban','tqq','renren']
}],
selectShare : [{
"bdselectMiniList" : ['qzone','tqq','kaixin001','bdxc','tqf']
}]
}
//分享按钮组织点击
$(".bds_more").on("click",function(){
return false;
})
with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='laodngjia2/news/jin10/js/share.js?cdnversion='+~(-new Date()/36e5)];

请求token:
<meta name="csrf-token" content="{{ csrf_token() }}"/>
$.ajaxSetup({
headers : {
'X-CSRF-TOKEN' : $('meta[name="csrf-token"]').attr('content')
}
});
<input type="text" id="table-currentDate" class="sp-currentDate table-currentDate" data-value='{{$date}}' value="{{$date}}" >

meta跳转:
<meta http-equiv="Refresh" content="0; url='baidu.jin10.com' " />

js日期格式函数:
Date.prototype.Format = function(fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}


本地存储demo:
var reportArr=['dc_chinese_ppi_yoy','dc_usa_interest_rate_decision'];
//本地存储报告数组
var curLocalArrKey='curLocalArr';
var curLocalArr= chartStorage.get(curLocalArrKey)|| reportArr;
if(curLocalArr[0]){
reportArr=[];
for(var i in curLocalArr){
reportArr.push(curLocalArr[i]);
}
}
chartStorage.set(curLocalArrKey,reportArr);


回到顶部:
$.fn.totop = function (opt) {
var scrolling = false;
return this.each(function () {
var $this = $(this);
var ftotop = function () {
if (!scrolling) {
var sd = $(window).scrollTop();
var sw = $(document).width();
if (sw >= 750 && sd > 100) {
$this.fadeIn();
} else {
$this.fadeOut();
}
}
};

ftotop();

$(window).scroll(function () {
ftotop();
});

$this.click(function () {
scrolling = true;
$('html, body').animate({
scrollTop: 0
}, 500, function () {
scrolling = false;
$this.fadeOut();
});
});
});
};
$("#backtotop").totop();


判断手机还是电脑:
function IsPC() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}

//预加载图片
function preloadimages(arr){
var newimages=[], loadedimages=0;
var postaction=function(){} ; //此处增加了一个postaction函数
var arr=(typeof arr!="object")? [arr] : arr;
function imageloadpost(){
loadedimages++;
if (loadedimages==arr.length){
postaction(newimages); //加载完成用我们调用postaction函数并将newimages数组做为参数传递进去
}
}
for (var i=0; i<arr.length; i++){
newimages[i]=new Image();
newimages[i].src=arr[i];
newimages[i].onload=function(){
imageloadpost()
};
newimages[i].onerror=function(){
imageloadpost()
}
}
return { //此处返回一个空白对象的done方法
done:function(f){
postaction=f || postaction
}
}
}
preloadimages(arr).done(function(){
//图片加载完成后的操作
})


mysql简单查询
update morning_paper_act set awardId=0;

froala编辑器引用:
<!-- Include Editor style. -->
<link href='https://cdnjs.cloudflare.com/ajax/libs/froala-editor/2.7.1/css/froala_editor.min.css' rel='stylesheet' type='text/css' />
<link href='https://cdnjs.cloudflare.com/ajax/libs/froala-editor/2.7.1/css/froala_style.min.css' rel='stylesheet' type='text/css' />
<!-- Include JS file. -->
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/froala-editor/2.7.1/js/froala_editor.min.js'></script>
$(‘#editor').editable({
inlineMode: false,
theme: 'gray',
//模版
height: '200px' //高度
});

 

posted @ 2017-11-16 11:33  泥娃拉拉  阅读(222)  评论(0编辑  收藏  举报