开发者

css : li hover doesn't work in internet explorer 6

开发者 https://www.devze.com 2023-03-12 06:06 出处:网络
here is the code : http://jsfiddle.net/yuliantoadi/hMr7h/ if 开发者_如何转开发you try to hover the \'test 2\' link, the dropdown menu will appear. the problem in IE 6, any idea how to make this dropd

here is the code : http://jsfiddle.net/yuliantoadi/hMr7h/

if 开发者_如何转开发you try to hover the 'test 2' link, the dropdown menu will appear. the problem in IE 6, any idea how to make this dropdown menu work in IE 6?


In IE 6, :hover only works on a tags for CSS. If you want hover effects for IE 6, they'll have to be done in Javascript.


you could use some JS to work around.

jquery sample:

$(function(){
    $('.link ul li').hover(
        function(){
          $(this).addClass('hover');  
        },function(){
            $(this).removeClass('hover');
    });
});

http://jsfiddle.net/hMr7h/1/


That's because IE 6 (and 7, if my memory serves) doesn't support the :hover pseudo-class on anything but a link.

You can, however, emulate the behavior with a bit of JavaScript (not using jQuery, unlike choise's answer):

var element = document.getElementById('someid'); // I'm leaving this part up to you.
element.onmouseover = function (e) {
    element.className += ' hover';
};
element.onmouseout = function (e) {
    elemen.className.replace(' hover','');
};
0

精彩评论

暂无评论...
验证码 换一张
取 消