While it's good practice to check for feature support rather then user agent, there's no simple way to check for something like support of a css property using JavaScript. I recommend you either follow the above posters suggestion of using conditional comments or use jQuery.browser. A simple implementation (not validated for performance or bugs) could look like this:
if ($.browser.msie && $.browser.version.substr(0,1)<7) {
// search for selectors you want to add hover behavior to
$('.jshover').hover(
function() {
$(this).addClass('over');
},
function() {
$(this).removeClass('over');
}
}
In your markup, add the .jshover class to any element you want hover css effects on. In your css, add rules like this:
ul li:hover, ul li.over { rules here }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…