1、链接去下划线
text-decoration: none;
添加下划线
text-decoration:underline;
点击input无边框
outline:none
2、onclick返回
οnclick="history.back();return false;"
οnclick="javascript:history.go(-1)"
3、input框不能为空
required="required"
4、三元运算符
(a==1)?2:3
5、重启阿帕奇服务器
service httpd restart
6、用逗号分割字符串
var arr=str.split(",");
alert(arr[1]);
截取字符串
str.substring(start,stop);截取start到stop之间的字符串,不包含stop
str.indexOf("a");返回a在str中的位置
7、点击inputt无边框
outline:none;
8、js遍历
prev();prevAll();之前的同胞元素
next();nextAll();之后的同胞元素
children();子元素 find()后代元素
parent();parents();父元素
siblings();所有同胞元素
9、验证码倒计时
var countdown = 60;
function settime(val) {
if (countdown == 0) {
val.removeAttribute("disabled");
val.value = "重发";
countdown = 60;
return;
} else {
val.setAttribute("disabled", true);
val.value = "已发送(" + countdown + ")";
countdown--;
}
setTimeout(function() {
settime(val)
}, 1000)
}
字符串转json对象
var obj = eval(strJSON);
var obj = strJSON.parseJSON();
var obj = JSON.parse(strJSON);
json对象转字符串
var str = obj.toJSONString();
var str = JSON.stringify(obj)
11、checkbox是否被选中
.is(":checked")
12、数组去重
var arr1=[1,2,1,2,3,4,6,5,6];
var arr2=[];
for(var i=0;i
14、获取url后的参数
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null)
return decodeURI(r[2]);
return null;
}
function fmoney(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}
function decimal(num,v)
{
var vv = Math.pow(10,v);
return Math.round(num*vv)/vv;
}
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;