如何使用javascript或jquery检测IE7并将类添加到div [英] How to detect IE7 with javascript or jquery and add a class to div

查看:63
本文介绍了如何使用javascript或jquery检测IE7并将类添加到div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以检测IE7吗?

Is there any way to detect IE7?

我在IE8中的代码没有任何问题,但在IE7中有问题.

I don't have any problems with my codes in IE8, but I have a problem with IE7.

所以我想的是,当浏览器是IE7通过javascript检测到它时,我可以使用jquery添加一个类.

So what I thought is that I can add a class with jquery when a browser is IE7 detecting it by javascript.

我要更改

<div id="system">

<div id="system" class="ie7">

谢谢.

推荐答案

您可以使用IE条件注释通过javascript来添加类,如下所示:

You could use an IE conditional comment to add the class via javascript, something like this:

<!--[if IE 7]>
<script type="text/javascript">
$(document).ready(function() {
    $('#system').addClass('ie7');
});
</script>
<![endif]-->

这篇关于如何使用javascript或jquery检测IE7并将类添加到div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆