全選反選應用:
<a href="#" class="all_choice">全選</a>/<a href="#" class="cancel_choice">反選</a>
$(document).ready(function(){
$(".all_choice").click(function(){
$('input[name=checkboxName]').each(function(){
$(this).attr("checked",true);
});
return false;
});
$(".cancel_choice").click(function(){
$('input[name=checkboxName]').each(function(){
if($(this).attr("checked")){
$(this).attr("checked",false);
}else{
$(this).attr("checked",true);
}
});
return false;
});
});
JQuery的ajax輕裝簡便:
$.ajax({
url:"url.action",--請求地址
type:"post",
dataType:"text",
data:"param="+param,--url跟的參數
error:function(){--錯誤處理
},
success:function(data){
--成功返回的信息
}
});