In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use jQuery.sub ()". In daily operation, I believe many people have doubts about how to use jQuery.sub (). The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to use jQuery.sub ()"! Next, please follow the editor to study!
JQuery.sub ()
Description: you can create a new copy of jQuery whose properties and methods can be modified without affecting the original jQuery object.
Added version: 1.5jQuery.sub ()
This method does not accept any parameters.
This approach is obsolete in jQuery1.7 and will be moved to a plug-in in jQuery version 1.8.
There are two cases in which you specifically use jQuery.sub () to create a copy of jQuery. The first case is that you want to rewrite the method of jQuery without breaking the original method. Another situation is that you want to do further encapsulation or basic namespaces for the jQuery plug-in.
Note that jQuery.sub () does not try to do any kind of isolation, because this is not what the method is intended to do. The methods in all jQuery copies still point to the original jQuery (for example, events are still bound and triggered through the original jQuery, and the data is bound to the element through the original jQuery. Ajax requests and events are also run through the original jQuery, and so on.) .
Please note that if you are looking to use this development plug-in, you should first seriously consider using some similar jQuery UI widget factories, these two state and plug-in management submethods. Use some examples of jQuery UI widget to create a plug-in.
The above examples describe the detailed usage of this method very well.
Example:
Example: add a method of jQuery so that it is not affected by the outer part:
(function () {
Var sub$ = jQuery.sub ()
Sub$.fn.myCustomMethod = function () {
Return 'just for me'
}
Sub$ (document) .ready (function () {
Sub$ ('body'). MyCustomMethod () / /' just for me'
})
) ()
Typeof jQuery ('body'). MyCustomMethod / / undefined
Rewrite some jQuery methods to provide new functionality.
(function () {
Var myjQuery = jQuery.sub ()
MyjQuery.fn.remove = function () {
/ / New functionality: Trigger a remove event
This.trigger ("remove")
/ / Be sure to call the original jQuery remove method
Return jQuery.fn.remove.apply (this, arguments)
}
MyjQuery (function ($) {
$(".menu") .click (function () {
$(this) .find (".submenu") .remove ()
})
/ / A new remove event is now triggered from this copy of jQuery
$(document) .bind ("remove", function (e) {
$(e.target). Parent (). Hide ()
})
})
) ()
/ / Regular jQuery doesn't trigger a remove event when removing an element
/ / This functionality is only contained within the modified 'myjQuery'.
At this point, the study on "how to use jQuery.sub ()" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.