FKa*_*FKa -2 html jquery clone
创建我自己的照片库我想加载小图片到更大的div来扩大它.首先,我使用html(),但它删除主(小)照片,或什么都不做(我发现几个解决方案如何使用html()而不是降低主要数据,但没有tchem工作).所以我尝试使用clone().但后来我尝试将它与html()结合起来,它给我一个错误:this.clone不是一个函数.我再次尝试找到解决方案,但没有任何效果.这是我尝试使用的解决方案和效果的代码:
<script>
var GallObj={
img:<?php echo json_encode($GetImg->jsonData); ?>,
imgIndex:new Number, //storage data about index of enlaging picture
}
var showAllImg = $.map(GallObj.img, function(val, i) {
return "<img src='gallery/"+val+"' class='smallimg'>";
});
$("#gallCont").html(showAllImg.join(""));
$('.smallimg').click(function(){
GallObj.imgIndex=$('.smallimg').index(this);
//it work, but I need change it and use html() because it doesn't change one loaded photo to new loaded photo of course:
$(this).clone().appendTo($('#picture'));
// this two removed clicked oryginalny picture and I don't want it:
$('#picture').html(this)
$('#picture').html(this).html();
//this.clone is not a function error:
elm=this.clone();
$('#picture').html(elm);
//this.clone is not a function error:
$('#picture').html(this.clone());
//do nothing:
$('#picture').clone().html(this);
//do nothing:
var value=$(this).html();
$("#picture").html(value);
$('#mask, #fixed, #picture, #close').css('display','block');
$('#mask').animate({'width':'100%','height':screen.height +100, opacity:'0.5'});
$('#picture').animate({width:'900'});
$('html, body').animate({scrollTop:0}, 1500);
})
</script>
Run Code Online (Sandbox Code Playgroud)
请帮帮我,解释一下我做错了什么......
| 归档时间: |
|
| 查看次数: |
2794 次 |
| 最近记录: |