1、select禁止下拉:
(1)查詢的清單為空。
(2)加上屬性:$("#selectRows").attr("disabled","disabled");
指派選擇的option:
$("#exfinancingClassifyth").html($("#exfinancingClassify").find("option:selected").text());
判斷:
<option value="9" <c:if test="${order.status==9}">selected="selected"</c:if>>已删除</option>
2、a标簽去除點選事件
(1)removeAttr('href');
(2)removeAttr('onclick');
3、span指派内容:$("#spanOne").text(“内容”);
修改span彈出文案:$("#spanOne").html(“内容”);
4、視窗居中:$("#div1").center();隐藏:$("#div1").hide();
5、正則比對(手機):
var reMobile=/^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))(\d{8})$/;
if(!reMobile.test(mobile)){ }
6、擷取根路徑:
//擷取目前網址,如: http://localhost:8088/test/test.jsp
var curPath=window.document.location.href;
//擷取主機位址之後的目錄,如: test/test.jsp
var pathName=window.document.location.pathname;
var pos=curPath.indexOf(pathName);
//擷取主機位址,如: http://localhost:8088
var localhostPaht=curPath.substring(0,pos);
//擷取帶"/"的項目名,如:/cms
var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
return(localhostPaht+projectName);
7、h5發送短信倒計時:
//初始化
var interValObj;
var count = 60;
var curCount = 0;
....
curCount=count;
$('#smsCode').removeAttr('href');
$("#smsCode").text(curCount+"s後可以重發");
interValObj=window.setInterval(setRemainTime,1000);
function setRemainTime(){
if(curCount==0){
window.clearInterval(interValObj);
$("#smsCode").attr("href","javascript:getSmsCode()");
$("#smsCode").text("重新發送驗證碼");
}else{
curCount--;
$("#smsCode").text(curCount+"s後可以重發");
}
}
8、轉化循環:
var result = eval('(' + data + ')');
var exfinancingList = result.exfinancingList;
if(exfinancingList.length != 0){
$('#financingId').html('');
$.each(exfinancingList,function(index,element){
var option ="<option value='"+this.id+"'>"+this.title+"</option>";
$('#financingId').append(option);
});
}
9、ajax的form表單對象送出:
$("#saveExfinancingJoinForm").serialize()
10、跳轉頁面對應div:
//其他頁面
window.location.href = "<%= request.getContextPath()%>/wf/finance?fc="+ef+"#activityRule";
//本頁面
window.location.hash = "#activityRule";
11、css賦樣式:
$(".hint").css({"display":"block"});
去除樣式:
$("div[name='divName']").removeClass(" act");
$("div[name='divName']").removeAttr("name");
$(obj).attr("name","divName");
$("div[name='divName']").addClass(" act");
var money = $("div[name='divName'] input[name='money']").val();
12、H5到頁面底部加載請求,如下一頁:
$(window).scroll(function () {
//已經滾動到上面的頁面高度
var scrollTop = $(this).scrollTop();
//頁面高度
var scrollHeight = $(document).height();
//浏覽器視窗高度
var windowHeight = $(this).height();
//此處是滾動條到底部時候觸發的事件,在這裡寫要加載的資料,或者是拉動滾動條的操作
if (scrollTop + windowHeight == scrollHeight) {
//請求操作
}
});