Reputation: 974
here i used hover function on jquery
. it works correctly. but i need selected li
on hover div.
$('.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();
});
});
when i hover rightside block(heading design,content design) the li
not selected. how to fix this?
Upvotes: 1
Views: 55
Reputation: 574
Try by adding class on hover
//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');
});
});
Upvotes: 1
Reputation: 28513
Try this: You don't need to use .each()
and then put hover. also need not to use class selector withid, you can use id selector directly (id must be unique through out the DOM) - see below code
$(".block-name").hover(function() {
$('.block-templates-container').hide();
var getId = $(this).attr('id');
$('#' + getId + '_show').show();
});
Upvotes: 0