开发者

Can I bind a jquery plugin at button click?

开发者 https://www.devze.com 2023-02-03 14:52 出处:网络
I would like to attach a plugin at runtime.The following code doesn\'t work.Maybe I think wrong way.Let me know the way you think.

I would like to attach a plugin at runtime.The following code doesn't work.Maybe I think wrong way.Let me know the way you think.

$(document).ready(function(){
   $('.show').click(function(){
     $('div.gallery img').slideGallery();
   });
});
<button class='show'>SHOW</button>
<div class="gallery">
//Images will appear from database by server side language.
&开发者_StackOverflow社区lt;/div>


The link that you posted is working fine for me.

Include the script file jquery.slidingGallery-1.2.min.js.

Call the plugin method in document ready event. It should work fine.

$(function(){
    $('div.gallery img').slidingGallery();
});

For this code to work you need to have images inside the div with class name gallery.

If you want to handle runtime generated elements then you might need to look into livequery.

0

精彩评论

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