我想为我的帖子内容做一个覆盖,比如“全屏模式对话框”。我一直坚持隐藏和显示我的内容和元素。我希望在显示内容时,元素将变得不可见。
$(function(){
$('.item').on('click',function(){
$(this).next('.content').css('display','block');
});
});
我也试过
var item= $(this).next('.content').detach();
$('body').html('').append(item.css('display','block');
但我必须重新加载页面才能返回到商品页面,这很糟糕。
最佳答案
使用
$('.item').on('click',function(){
$('.content').hide(); // hide
$(this).next('.content').show(); // show
});
有动画
$('.item').on('click', function () {
$('.content').hide("slow", function () {
// Animation complete.
}); // hide
$(this).next('.content').show("slow", function () {
// Animation complete.
}); // show
});
关于javascript - 使用 jquery 隐藏和显示覆盖模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27701695/