Defining your own functions in jQuery

22 בספטמבר 2008

Defining your own functions in jQuery. In this post i want to present how easy define your own functions in jQuery and using them. As you know, jQuery it's a very rich JavaScript library and it's a pity not to use all it resources. Ok. Do you want to create your own jQuery function to work with elements look like this: $(element).yourfunctionname() What is your steps to define it? At first, define "jQuery.fn" and add to this object your function name see below. (jQuery.fn is a prototype of jQuery object) jQuery.fn.yourfunctionname = function() { var o = $(this) // It's your element}; Now you...
תגיות: , , ,
22 תגובות