This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function htmlEncode(str) { | |
var div = document.createElement("div"); | |
div.appendChild(document.createTextNode(str)); | |
return div.innerHTML; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = document.getElementById("eq").offsetTop; | |
if (a >= $(window).scrollTop() && a < ($(window).scrollTop()+$(window).height())) { | |
alert("div在可视范围"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//方法一: | |
if(typeof(jQuery) == 'undefined'){ | |
console('yes'); | |
}else{ | |
console('no'); | |
} | |
//方法二: | |
if(window.jQuery){ | |
console('yes'); | |
}else{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 功能: 1)去除字符串前后所有空格 | |
// 2)去除字符串中所有空格(包括中间空格,需要设置第2个参数为:g) | |
function Trim(str,is_global) | |
{ | |
var result; | |
result = str.replace(/(^\s+)|(\s+$)/g,""); | |
if(is_global.toLowerCase()=="g") | |
result = result.replace(/\s/g,""); | |
return result; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div{word-break:break-all;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* transform the Date to String according the format pattern | |
* eg: | |
* (new Date()).format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 | |
* (new Date()).format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 | |
*/ | |
exports.dateFormat = function(date,fmt) { | |
var o = { | |
"M+" : date.getMonth() + 1, | |
"d+" : date.getDate(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 获取当前时间 | |
*/ | |
exports.getNowTime = function(){ | |
return exports.dateFormat(new Date(),"yyyy-MM-dd hh:mm:ss"); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************** | |
** http://www.cnblogs.com/xpnew/archive/2008/07/31/1257144.html | |
**比较通用的正则表达式,捕获url各个部分。 | |
**注意各部分基本上都包含了相应的符号,例如端口号如果捕获成功,那就是':80' | |
**函数返回一个正则表达式捕获数组。 | |
**注意,现在获得的是一个数组,所以需要通过arr[i]的方式引用。 | |
**正则表达式所有的匹配说明:: | |
**$0 | |
**整个url本身。如果$0==null,那就是我的正则有意外,未捕获的可能。 | |
**有一种未捕获的情况已经被发现,那就是域名后面没有以'/'结尾,如:'http://localhost' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE wordlist set demo = REPLACE(demo,'/iWord','/word') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hasClass(el, name) { | |
return new RegExp('(\\s|^)'+name+'(\\s|$)').test(el.className); | |
} | |
function addClass(el, name) | |
{ | |
if (!hasClass(el, name)) { el.className += (el.className ? ' ' : '') +name; } | |
} | |
function removeClass(el, name) | |
{ |