Codepen Demo
这里我在 jquery
上使用了悬停功能。它工作正常。但我需要在悬停 div 上选择 li
。
$('.block-templates-container:not(:first-child)').hide();
$(".block-name").each(function() {
$(this).hover(function() {
$('.block-templates-container').hide();
var getId = $(this).attr('id');
$('.block-templates-container#' + getId + '_show').show();
});
});
当我将鼠标悬停在右侧 block (标题设计、内容设计)时,未选择 li
。如何解决这个问题?
最佳答案
尝试在悬停时添加类
//Sidebar
$('.block-templates-container:not(:first-child)').hide();
$(this).hover(function() {
$('.block-templates-container').hide();
var getId = $(this).attr('id');
$('.block-templates-container#' + getId + '_show').show();
$('.block-name').not(this).removeClass('current');
$(this).addClass('current');
});
});
关于jquery - 如何在jquery中添加当前类选择的div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37606639/