开发者

How to add a class with if statement in conditional statement with jquery?

I am having a problem with IE7 in a certain page where URL has katoder, http://www开发者_C百科.mywebsite.com/Kalde_katoder.asp

I want to add a class ie7 to id system.

I tried this but it does not work.

Could anyone point me to the right direction?

Thanks in advance.

<!--[if IE 7]>

<script type="text/javascript">

$(document).ready(function() {
if(location.pathname.indexOf('katoder') > 0){
    $('#system').addClass('ie7');
}
});

</script>

<![endif]-->


jQuery.browser Can Do the job

   $(function() {
      if($.browser.msie && parseInt($.browser.version) == 7) {
        if(location.pathname.indexOf('katoder') > 0){
            $('#system').addClass('ie7');
         }
      }
    });


Not sure what you're trying to do, but you probably don't need to use JavaScript. See http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/

Next, target your div with the ie7 class.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜