JQuery, as a lightweight JS framework, has its unique advantages. Many web programmers are happy. In addition to rich client processing and animation functions. It also provides custom extension interfaces for more people to develop extension JQuery. Use a simple example to demonstrate this interface. I think this is enough for many people to understand the path. The following example references JQuery APIs.
$.extend({ max: function(a, b) { return a > b ? a : b; }, min: function(a, b) { return a > b ? b : a; }, avg: function(a, b) { return a / b; }});
This example adds a new function to JQuery, which is a static function.
The call is as follows:
jQuery.min(2,3); // => 2jQuery.max(4,5); // => 5
It is also very easy to extend functions for components. For example, you want to extend the TextBox function so that it can be highlighted when the focus is obtained. If the focus is lost, the highlight is canceled. Of course, the highlighted effect can be implemented using CSS. Therefore, you can use a color name as a parameter. The Code is as follows:
$. Fn. hightlight = function (colorName) {this. mouseover (function () callback (this).css ('background-colorName); // this is a reference to the component itself}); this. mouseout (function () callback (this).css ('background-color ','');});}
The call is as follows:
$(function() {$('#test').hightlight('red');});Articles you may be interested in
- PHP obtains the week of the specified date, the first day of the month and the last day of the month.
- Js address bar special effects (display the size of all images with links on the page and view the height of the current browser)
- Php SDK for retrieving pm2.5 data from a certain place (pm2.5 php api)
- How to Use constants defined by define in a program in a smarty Template
- QQ floating Customer Service Code, very easy to expand
- How to obtain the complete url address and parameters in javascript
- CSS intercepts strings to automatically add ellipsis
- Extension of the for loop in the smarty Template