Frzzy
Frzzy

Reputation: 309

addClass removeClass not working in IE..!

jQuery functions addClass and removeClass do not work properly when I use them to change the appearance of a div tag in Internet Exploer (IE). However, they work fine in other browsers.

Here is sample code to illustrate my problem:

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>

Upvotes: 3

Views: 10954

Answers (3)

user4860938
user4860938

Reputation: 9

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 no da problemas.

--Edit in english--

with ExtJs : class: 'xxx - readonly ' is supposed to already have the input this kind , it is necessary to focus ( senderField.focus (true , 12) ) , for IE, and other browsers again, this does not It gives problems .

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

Upvotes: 0

MicRum
MicRum

Reputation: 1721

Try it

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

Upvotes: 1

user1976613
user1976613

Reputation:

Try adding <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> inside the head tag or this <meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1">

Make sure you are executing the script that adds and removes the classes after the one that adds tha .current class or try running the script that adds and remove classes inside an $(window).bind("load", function(){ ... your code for the load event ... });

Upvotes: 0

Related Questions