2013-06-12 74 views
2

当我使用它们来更改Internet Explorer(IE)中的div标记的外观时,jQuery函数addClass和removeClass无法正常工作。但是,它们在其他浏览器中运行良好。addClass removeClass在IE中不工作..!

下面是示例代码来说明我的问题:

if ($('#tdh').hasClass('current')){ 
    $("#u50").addClass('u59c'); 
    $("#u59").addClass('u59b'); 
    $("#u61").removeClass('u59b'); 
} 

CSS:

.u59b { 
    background-color: #3B5998; 
    color: #FFFFFF; 
    font-family: Segoe UI Light; 
    font-style: normal; 
    font-weight: bold; 
    padding-right: 13%; 
    text-decoration: none; 
    width: 196px; 
} 

.u59c { 
    color: #3B5998; 
    font-family: Segoe UI Light; 
    font-style: normal; 
    font-weight: bold; 
    padding-left: 10%; 
    text-decoration: none; 
} 

HTML

  <a href="Page/tdh.aspx" id="tdh" class="current"> 
      <div id="u59" class="u59 u124-pad"> 
       Title1 
      </div> 
      </a> 
      <a href="Page/tdh2.aspx" id="tdh2"> 
      <div id="u63" class="u59 u59b u124-pad"> 
       Title2 
      </div> 
      </a> 
+3

显示你的HTML标记 – Curt

+2

哪个版本的IE? –

+1

'addClass'和'removeClass'工作。别的东西没有用。 –

回答

0

尝试增加<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> head标签 内或本<meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1">

确保您正在执行,增加和补充塔.current类或尝试运行,增加了脚本,删除里面的$(window).bind("load", function(){ ... your code for the load event ... });

1

类尝试一前一后删除类的脚本它

if ($('#tdh').hasClass('current')){ 
    $("#u50").attr('class','u59c'); 
    $("#u59").attr('class','u59b'); 
    $("#u61").removeAttr('class'); 
} 
0

con ExtJs:class:'xxx-readonly',se supone que ya tiene esta clase el input,es necesario poner otra vez el foco(senderField.focus(true,12)),para IE,y para los otros navegadores,esto没有问题。

- 编辑在english--

与ExtJS的:类: 'XXX - 只读' 应该已经输入这样的,它是要重点(senderField.focus(真,12 )),对于IE和其他浏览器,这不会产生问题。

field.addListener('focus', function(senderField){ 
    this.readOnly = this.el.dom.readOnly = false; 
    this.getActionEl().removeClass('xxx-readonly'); 
    senderField.focus(true, 12); 
}); 
+2

请在这个网站上使用英语。 – rmtheis

相关问题