Tương tác giữa PHP và jQuery - part 36

Phương pháp Thêm vào jQuery Để thêm một phương thức chainable đến đối tượng jQuery, bạn có để gắn nó vào các đối tượng fn của jQuery. Điều này cho phép bạn gọi phương thức trên một tập hợp các thành phần được chọn: $ ("class"). YourPlugin ();. | CHAPTER 10B EXTENDING JQUERY Adding Methods to jQuery To add a chainable method to the jQuery object you have to attach it to the fn object of jQuery. This allows you to call the method on a set of selected elements .class .yourPlugin Note The fn object of jQuery is actually just an alias for the jQuery object s prototype object. Modifying the prototype of an object will affect all future instances of that object rather than just the current instance. For more information on this check out the brief and simple explanation of the prototype object in JavaScript at http javatutors . Building Your Plugin The plugin you ll build in this section will rely on a simple method to enlarge the event titles when a user hovers over them and then return them to their original size when the user moves his mouse off the title. This plugin will be called dateZoom and it will allow the user to configure the size speed and easing equation used for the animation. Creating a Properly Named Plugin File Your first order of business when creating this plugin is to give it a name. Create a new file in the js folder called and insert the custom alias function function plugin code here jOuery Inside this function attach the new method to the fn object by inserting the following bold code function A plugin that enlarges the text of an element when moused over then returns it to its original size on mouse out . function options code here jQuery 351 CHAPTER 10 EXTENDING JQUERY Providing Publicly Accessible Default Options In your validDate plugin the function s default options are stored in a private object. This can be undesirable especially in instances where a user might apply the plugin method to multiple sets of elements and then want to modify the defaults for all instances. To make default options publicly accessible you can store them in the dateZoom namespace. For your dateZoom plugin create a publicly accessible defaults .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
55    95    2    28-06-2024
94    845    1    28-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.