Use code for the Live method and $. browser method under JQuery

Source: Internet
Author: User

Copy codeThe Code is as follows:
$ (Function (){
Ajaxload ("? Uid = 1 <% = Yan. GET_Dict (id, 8, TableName) %> ")
$ ("# ThreeM a: first"). addClass ("addBg ");
$ (". PageP2 "). live ("click", function () {var NewUrl = $ (this ). attr ("href"); if (jQuery. browser. msie) {var IE = $. browser. version; if (IE = "7.0" | IE = "6.0") {NewUrl = "? "+ NewUrl. split ('? ') [1] }}; Ajaxload (NewUrl); return false ;});/* return false to prevent the default a tag jump, use ajax Request */
$ ("# ThreeM a"). click (function (){
If (! $ (This ). hasClass ("addBg") {$ ("# ThreeM "). removeClass ("addBg"); $ (this ). addClass ("addBg ")}
Var Url = "? Uid = 1 "+ $ (this). attr (" id ");
Ajaxload (Url );
})
})
Function Ajaxload (parm)
{
$. Ajax ({
Type: "GET ",
Url: "/stus/3th. aspx" + parm,
Cache: false,
BeforeSend: function () {$ ("# Three" inline .html ("<div> load... </div> ")},
Success: function (msg ){
$ ("# Three" cmd.html (msg );
},
Error: function () {$ ("# Three" example .html ("Load failure ...")}
});
}

The jQuery. browser method has the following parameters and returns true or false: 
Safari
Opera
Msie
Mozilla
It is determined by referencing the browser here, because the href = "? Uid = "the whole address is obtained. I don't know why. Use split to intercept...

The $. live () method is a newly added function in 1.3.2, which supports custom events in 1.4.1. Check the api for details...

In addition, bubble of the live method:

The dynamically generated a tag obtained by the ajax commit is bound to the click event using the Live () method. The second query will execute two click events and bubble up. If you use the one () method, one click will become invalid.

Finally, bind () is used to Unbind cilick. You can.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.