Mootools 1.4.1 operate on multiple nodes and its differences with jquery

Source: Internet
Author: User
Tags mootools

Today, I encountered an interesting multi-node operation during the development process. I would like to share it with you and compare the differences between Mootools and jquery.

Since jquery was used before, it is difficult to change the inertial thinking after it is transferred to mootools. As a result, this problem was found today, if the statement of Mootools is written in jquery, it cannot achieve the expected results. Therefore, multiple nodes must be disassembled using the Array each method. it can be seen that mootools is closer to js prototype development.

Let's look at the code at the bottom of the pipeline:

// Mootools practices:
Function Global_HidShow_Other (I ){
I = $ (I );
If (I. checked ){
$ Sel = $('srh1 '). getElements ('Li. float input ');

Array. each ($ sel, function ($ sel _, index ){
$ Sel _. checked = false;
$ Sel _. disabled = true;
});
}
}

// Jquery practices
$ (Document). ready (function (){
$ Sel = $ ('# srh1 li. float input ');
$ Sel. checked = false; // I remember that when I was writing jquery, it seemed that there was a problem with the direct operation of checked and disabled. It took a long time and it was hard to remember.
$ Sel. disabled = true;
});

In fact, this should be a very basic thing, just thanks to jquery's habit.

The Global_HidShow_Other function is not bound to events, but is directly written to the dom node. <font onclick = "Global_HidShow_Other (this)">, in this way, you do not need to bind events every time you open the page, whether or not you can use this function or not. You can save resources.

I passed this during the call. To be compatible with IE, I =$ (I) before using the I parameter to avoid IE errors.

Is this usage very similar to js prototype development? It seems that everything is attributed to the source.

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.