I have this conditional function in jQuery, in order to show an specific message with it's own style when required:
function msg(type, text) {
    if (type="success"){
        $('.messageDisplay').attr('class', 'messageDisplay messages success');
        $('.messages').text(text);
        $('.messages').stop( true, false ).fadeIn(300).delay(2000).fadeOut(450);}
    else if (type="info"){
        $('.messageDisplay').attr('class', 'messageDisplay messages info');
        $('.messages').text(text);
        $('.messages').stop( true, false ).fadeIn(300).delay(2000).fadeOut(450);}
    else if (type="error"){
        $('.messageDisplay').attr('class', 'messageDisplay messages error');
        $('.messages').text(text);
        $('.messages').stop( true, false ).fadeIn(300).delay(2000).fadeOut(450);}
    else if (type="warning"){
        $('.messageDisplay').addClass('messages warning');
        $('.messages').text(text);
        $('.messages').stop( true, false ).fadeIn(300).delay(2000).fadeOut(450);}}
When call it, it only takes first condition, as the class that is always added to the messageDisplay div is 'messageDisplay messages info'. For example, on this case I am calling the "error" message type:
$('.tableContent').on('click', '.editIcon', function (e){
        if (editing==1){
            msg("error", "Acepta o anula la edición actual antes de editar otro registro");}
And even when it takes the right text, generates a success style message:
<div class="messageDisplay messages success">Acepta o anula la edición actual antes de editar otro registro</div>
After checking several times what could be causing this behaviour in jQuery, I am unable to find it and I'm almost sure no other jQuery's function is causing this. Is it something wrong on the conditional?
 
     
     
    