1、 js判断字符串是否为空
var str="";
//if(" "==str||' '=str){
if(str){
alert("为空");
}
2、判断checkbox是否被选中
js判断checkbox是否被选中
var c = document.getElementById("protocl");
if(!c.checked){
alert("未选中“);
return;
}
jQuery判断checkbox是否被选中
if($("#cboxapple").is(':checked')){
alert("1")
}
3、JS定时器setInterval()和setTimeout()延时器的用法
3.1 执行不带参数的函数
window.setTimeout(函数名,毫秒数);
//例如window.setTimeout(list,5000); 表示延时5秒执行函数list();
3.2 执行带参数的函数
window.setTimeout(函数名,毫秒数,参数1,参数2,...);
注:延时器不会自动重复
clearTimeout( )取消延时器
3.3 定时器
var int=self.setInterval(函数名,毫秒数);
注:定时器会自动重复
clearInterval( )取消定时器