您的位置:首页 > Web前端 > JQuery

jquery相关常用的工具函数

2017-10-20 14:28 417 查看
1.弹出提示框:

function prompt(msg){
$("<div>" + msg + "</div>").css({
"width": "200px",
"padding": "15px",
"line-height": "1.5em",
"text-align": "center",
"background": "rgba(51,51,51,.8)",
"color": "#fff",
"border-radius": "5px",
"box-shadow": "1px 1px 5px rgba(204,204,204,.4)",
"position": "absolute",
"z-index": "10000",
"top": "0",
"left": "50%",
"margin-left": "-100px"
}).appendTo("body").animate(
{top: "35%"},"normal", "linear",function() {
$(this).delay(500).fadeOut(1000,function() {
$(this).remove()
})
})
}


  2.js 网址URL查询:

function urlQuery(){
var url = location.search;
var obj = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
obj[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
}
}
return obj;
}


  3.jquery高级版本(3.2测试不支持)不支持如下的写法

$().load(function(){

})


  报错:

Uncaught TypeError: a.indexOf is not a function


  高版本请使用:

$().on('load',function(){});替代


  

都很简单,示例就不写了。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: