1.指定在主页面某个div中中显示子页面内容 ,其中renderContainer 可以是主页面div的id或者name
$.ajax({
url: url,
data: parameters,
type:”GET”,
dataType:”html”,
success:function (html) {
$(renderContainer).attr(“title”, title);
$(renderContainer).html(html);
$(renderContainer).dialog({
autoOpen: true,
width: 590,
height: 720,
modal: true,
resizable: false,
draggable: true
});
}
});
2.选择指定表的指定属性的指定ID 进行某项动作
$(“.tbl_checked tr[userid='” + idArray[i] + “‘]”).remove();
3.延迟加载触发事件,选择 id 中包含“userid”字段且被勾选 的checkbox,并把它们的id 放在idArray 数组里
$(“#authorize_reset”).live(‘click’,function(){
var idArray = [];
$(“:checkbox[id^=’userid’]”).each(function(){
if($(this).attr(“checked”) == “checked”){
idArray.push(parseInt($(this).val()));
}
});
});
});
3. 选择 id 中包含“userid”字段且被勾选 的checkbox 的另一种写法
$(“:checkbox[id^=’userid’][checked]”).each(function(){
selectedRoleIdArray.push(parseInt($(this).val()));
});
4.简单实用的点击改变样式
$(function(){
$(“.tbl_checked tr”).live(‘click’, function(){
var target = $(this);
if(target.attr(“class”) == “tr_checked”) {
target.removeClass(“tr_checked”);
} else {
target.addClass(“tr_checked”);
}
})
5.“2012-12-21” 格式的时间比较大小,需要先转换
var compareTime = Date.parse(setTime.replace(/-/g, “/”));
6.获取“2012-12-21” 格式的当前时间
(function ($) {
var FormatDateTime = function FormatDateTime() { };
$.FormatDateTime = function (days) {
//var correcttime1 = eval(‘( new ‘ + obj.replace(new RegExp(“/”, “gm”), “”) + ‘)’);
var myDate = new Date();
myDate.setDate(myDate.getDate()+days);
var year = myDate.getFullYear();
var month = (“0” + (myDate.getMonth() + 1)).slice(-2);
var day = (“0” + myDate.getDate()).slice(-2);
var s=year+”-“+month+”-“+day;
return s ;
}
})(jQuery);
最后是一个用jquery弄的类似双向列表,可以左右交换内容
$(function(){
//点击 加载用户列表,角色用户列表
$(“.add_remove_user”).live(‘click’,function() {
var rid = $(“.current”).attr(“id”).substring(“ut_”.length);
changeroleDialog(changeroleRoute.url(), {id: rid}, “.set_user_list”);










