jQuery auto-apply plugins
wrote a little jquery gallery plugin and i'm initializing like this: myDiv.tGallery();
my question: is it possible to have jQuery detect if the HTML markup contains gallery code (eg. defined by its classname .myPlugs_gallery) and auto-apply the plugin code?
currently i'm having a global init-routine which goes like $(".myPlugs_tGallery").tGallery();
i was thinking about some kind of dynamic jQuery statement like: "apply plugincode to all divs which start with classname "myPlugins"
so there would be just one command for all my future plugins.
any i开发者_开发问答deas how to do it? thanks
Add an initialization block to your plugin .js file:
$(function() {
$('div.myPlugs_gallery').tGallery();
});
try this with if statment
$('div:eq(.myPlugs_gallery)')
精彩评论