2015-07-19 30 views
0

我不知道该怎么做:用jquery的每一个滚动9个图像的数组,并动态地构建一个三列的网格。对于每个图片点击这应该消失与淡入淡出效果具有每个函数的Grid JQuery

回答

0

这是你的意思?

<style> 
    #print{width: 141px;height: 141px;margin: auto;} 
    #print div{width:35px;height:35px;margin: 5px;border: 1px solid #000;float:left;} 
    #print div img{width:35px;height:35px;} 
</style> 
<script> 
    var r = ''; 
    array = ['1','2','3','4','5','6','7','8','9']; 
    for(var i = 0 ;i < 9; i++){ 
     r += '<div><img src="https://www.gravatar.com/avatar/b704656821750c1f0abf7832da997248?s=32&d=identicon&r=PG&f=1" /></div>'; 
     //when replace your images names at array replace src with this src="images/'+array[i]+'.jpg" 
    } 
    function fadeOutFunction(){ 
     img = $(this).children('img'); 
     img.fadeToggle(); 
    } 
    $(document).ready(function(e) { 
     $('#print').html(r); 
     $('#print').delegate('div','click',fadeOutFunction); 
    }); 
</script> 
<div id="print"></div>