2013-06-12 75 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

相關問題