Multiple Javascript Gadgets Per Page
I'm writing an in-house gadget in Javascript and jQuery. I've written it in an object-oriented manner with a top-level object called, as an example ggObj and assigned methods via g
Solution 1:
You probably want to look at creating a jQuery plugin.
$.fn.MYPLUGINNAME = function() {
returnthis.each(function() {
//your code to manipulate the element here//you can use this to refer to a specific instance of an element//if you apply the plugin to multiple elements on the page.
});
}
You can then add MYPLUGINNAME to any element on the page.
$('a').MYPLUGINNAME();
So to do animation etc you can now use the built in jQuery animation() functions.
There are several tutorials online that could help. Like this:
Solution 2:
It looks like you simply need a little OO.
Post a Comment for "Multiple Javascript Gadgets Per Page"