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.