开发者

jQuery auto-apply plugins

开发者 https://www.devze.com 2022-12-19 11:28 出处:网络
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

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)')
0

精彩评论

暂无评论...
验证码 换一张
取 消