我在修改代码时遇到了一些麻烦。我正在研究这个"google like" image preview 。正如您所看到的,前三个图像预览工作正常。我需要第四张图片才能开始工作,因为我的 HTML 看起来像第四张图片,并且只有当用户单击图片“快速查看”div 时才会进行预览。
脚本
<script>
// hide all
$('.descriptions .panel').hide();
// show first
//$('#descriptions .panel').eq(0).show();
// handle img click
$('#grid img').click(function(){
// get index of the img that was clicked
var idx = $(this).parent().index();
var row = $(this).parent().parent().next('.row');
// remove special style from all others
$('#grid img').removeClass('highlight');
// add a special style to the clicked image
$(this).addClass('highlight');
// hide all others
$('.descriptions .panel').hide();
// show desc for clicked img
row.find('.descriptions .panel').eq(idx).show("slow","swing");
});
</script>
您能否帮助如何修改此代码来解决我的问题。如果您需要任何其他信息,请告诉我,我会提供
最佳答案
// hide all
$('.descriptions .panel').hide();
// handle img click
$('.col-md-3').click(function(){
// get index of the img that was clicked
var idx = $(this).index();
var row = $(this).parent().next('.row');
// remove special style from all others
$('#grid img').removeClass('highlight');
// add a special style to the clicked image
$(this).find('img').addClass('highlight');
// hide all others
$('.descriptions .panel').hide();
// show desc for clicked img
row.find('.descriptions .panel').eq(idx).show();
});
试试这个希望有帮助:)
关于javascript - "Google like"图像预览按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36194459/