1. Specifies that the child page content is displayed in a div in the main page, where rendercontainer can be the ID or name of the main page div
Copy Code code as follows:
$.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. Select the specified ID of the specified table to perform an action
Copy Code code as follows:
$ (". Tbl_checked tr[userid= '" + idarray[i] + "']"). Remove ();
3. Delay loading trigger event, select checkbox containing "userid" field in ID, and place their ID in IDArray array
Copy Code code as follows:
$ ("#authorize_reset"). Live (' click ', function () {
var idarray = [];
$ (": checkbox[id^= ' userid ']"). each (function () {
if ($ (this). attr ("checked") = = "Checked") {
Idarray.push ($ (this). Val ()) (parseint);
}
});
});
});
3. Another way to choose a checkbox that contains a "userid" field in the ID and is checked
Copy Code code as follows:
$ (": checkbox[id^= ' userid '][checked]"). each (function () {
Selectedroleidarray.push ($ (this). Val ()) (parseint);
});
4. Simple and practical Click Change Style
Copy Code code as follows:
$ (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" format of the time comparison size, need to first convert
Copy Code code as follows:
var comparetime = Date.parse (Settime.replace (/-/g, "/"));
6. Get current time for "2012-12-21" format
Copy Code code as follows:
(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);
Finally, a kind of bidirectional list with jquery to exchange content
Copy Code code as follows:
$ (function () {
Click to load user list, role user list
$ (". Add_remove_user"). Live (' click ', function () {
var rid = $ (". Current"). attr ("id"). substring ("ut_". length);
Changeroledialog (Changeroleroute.url (), {Id:rid}, ". Set_user_list");
});
<!--Highlight Begin-->
$ (". tbl_checked tr"). Live (' click ', function () {
var target = $ (this);
if (target.attr ("class") = = "Tr_checked") {
Target.removeclass ("tr_checked");
} else {
Target.addclass ("tr_checked");
}
});
$ (". tb1_role_checked tr"). Live (' click ', function () {
var target = $ (this);
if (target.attr ("class") = = "Tr_checked_1") {
Target.removeclass ("Tr_checked_1");
} else {
Target.addclass ("Tr_checked_1");
}
});
<!--Highlight End-->
<!--click the "Add/Remove" button to move the contents of the list begin-->
$ ("#addThisRole"). Live (' click ', function () {
if ($ (". tb1_role_checked tr").-A (). attr ("default_value") = = ' Noresult ') {
var table = $ (". tb1_role_checked");
$ (". tb1_role_checked tr"). Remove ();
var tr = $ ("<tr ></tr>")
. Append ($ ("<th></th>"). html (' name ')
. Append ($ ("<th></th>"). HTML (' account ')
Table.append (TR);
}
$ (". tr_checked"). each (function () {
$ (this). Remove ();
var element = $ (this);
var id = element.attr ("param_id")
var name = element.attr ("Param_name")
var account = element.attr ("Param_account")
var table = $ (". tb1_role_checked");
var tr = $ ("<tr param_roleid= '" +id+ "' param_rolename= '" +name+ "' param_roleaccount= '" +account+ "' style= ' cursor: Pointer ' ></tr> ')
. Append ($ ("<td></td>"). HTML (element.attr ("Param_name"))
. Append ($ ("<td></td>"). HTML (element.attr ("Param_account"))
Table.append (TR);
Tr.insertafter ($ (". tb1_role_checked tr").
});
});
$ ("#deleteThisRole"). Live (' click ', function () {
if ($ (". tbl_checked tr").-A (). attr ("default_value") = = ' Noresult ') {
var table = $ (". tbl_checked");
$ (". tbl_checked tr"). Remove ();
var tr = $ ("<tr ></tr>")
. Append ($ ("<th></th>"). html (' name ')
. Append ($ ("<th></th>"). HTML (' account ')
Table.append (TR);
}
$ (". Tr_checked_1"). each (function () {
$ (this). Remove ();
var element = $ (this);
var id = element.attr ("Param_roleid");
var name = element.attr ("Param_rolename");
var account = element.attr ("Param_roleaccount");
var table = $ (". tbl_checked");
var tr = $ ("<tr param_id= '" +id+ "' param_name= '" +name+ "' param_account= '" +account+ "' style= ' Cursor:pointer ' >< /tr> ")
. Append ($ ("<td></td>"). HTML (element.attr ("Param_rolename"))
. Append ($ ("<td></td>"). HTML (element.attr ("Param_roleaccount"))
Table.insertbefore (TR, $ (". tbl_checked tr").
Tr.insertafter ($ (". tbl_checked tr").
});
});
});
First so much, the above code is not perfect, need to improve the place I hope that we do not hesitate to advise.