$(function(){ $(".header .fr .items").each(function(){ $(this).children(".item") var itemwidth = $(this).children(".item").width() $(this).children(".item").css("margin-left", -(itemwidth / 2)) }) $(".header .fr .items .a1").hover(function(){ $(this).css("border-bottom","solid 2px #ef9112") },function() { $(this).css("border-bottom","none") if($(this).hasclass("active")){ $(this).css("border-bottom","solid 2px #ef9112") } }) $(".header .fr .items .item").hover(function(){ $(this).siblings(".a1").css("border-bottom","solid 2px #ef9112") },function() { $(this).siblings(".a1").css("border-bottom","none") }) $('.erpage .item').hover(function () { $(this).addclass('active') },function() { $(this).removeclass('active') }) $(".header .open").click(function() { $(".headernav").slidedown(); $(this).hide() $(".header .close").show() }); $(".header .close").click(function() { $(".headernav").slideup(); $(this).hide() $(".header .open").show() }); $('.headernav ul li').click(function(){ $(this).toggleclass('active'); $(this).children('.item').slidetoggle() }) })