個人簡便代碼

*{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; }javascript

 

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; }php

y軸滾動:overflow-y: scroll;css

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

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));html5


頭文信息:
<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" />java

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

禁打電話:<meta name="format-detection" content="telephone=no" />
禁止連接高亮:-webkit-tap-highlight-color:rgba(0,0,0,0);
禁止連接長按彈出選項菜單:-webkit-touch-callout:none;jquery

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


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


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.五、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' //高度 });

相關文章
相關標籤/搜索