-1

我正在尝试使此功能正常工作。我试图让它仅在单击 li 时执行读取 xml 的函数

以下是我的 jQuery:

     <script>
                $("ul.productcat li").on('click', function (e) {
                    var $this = $(this),
                        // Class of the one to be shown
                        subclazz = $this.data("class"); 
                        $('article > div').removeClass('show');
                        $('.' + subclazz).addClass('show');                  
                    mygallery(subclazz);
                });
            </script> 
            function mygallery(config){ 
            <script type="text/javascript" src="gallery/js/jquery.js"></script> 
            <script type="text/javascript" src="gallery/js/swfobject.js"></script> 
            <script type="text/javascript" src="gallery/js/flashgallery.js"></script> 
            <script type="text/javascript">
                jQuery.flashgallery('gallery/gallery.swf', 'gallery/'+config+'.xml', { width: '650px', height: '600px', background: 'transparent' });
            </script>
    }

任何帮助,将不胜感激。

4

2 回答 2

2

你应该做类似的事情:

//load all the scripts
<script type="text/javascript" src="gallery/js/jquery.js"></script> 
<script type="text/javascript" src="gallery/js/swfobject.js"></script> 
<script type="text/javascript" src="gallery/js/flashgallery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $("ul.productcat li").on('click', function (e) {
        var $this = $(this),
        // Class of the one to be shown
        subclazz = $this.data("class");                   
        mygallery(subclazz);
    });
});
function mygallery( config ) {
    jQuery.flashgallery('gallery/gallery.swf', 'gallery/'+config+'.xml', { 
         width: '650px', 
         height: '600px', 
         background: 'transparent' 
    });
}
</script>
于 2013-08-22T03:53:00.117 回答
0
  function mygallery(config){ 
<script type="text/javascript" src="gallery/js/jquery.js"></script> 
        <script type="text/javascript" src="gallery/js/swfobject.js"></script> 
        <script type="text/javascript" src="gallery/js/flashgallery.js"></script> 
        <script type="text/javascript">
            jQuery.flashgallery('gallery/gallery.swf', 'gallery/'+config+'.xml', { width: '650px', height: '600px', background: 'transparent' });
        </script>
}

在某一方面的变化

 function mygallery(config){  
jQuery.flashgallery('gallery/gallery.swf', 'gallery/'+config+'.xml',
 { width: '650px',
 height: '600px',
 background: 'transparent'
 }
);
}
于 2013-08-22T03:52:21.897 回答