Search code examples
cssbackgroundinternet-explorer-9mootools

Mootools .setStyle doesn't change background color in IE9


I have a MooTools script, which handles panel with buttons (switching the panel content).

Here is the script - every button sets corresponding panel visible + change a background of itself:

buttons.addEvent('mouseenter', function(button){
        var panel = 'panel-' + this.get("id");
        $$('.panel').setStyle('display','none');
        $(panel).setStyle('display','block');
        buttons.setStyle('background',null);
        this.setStyle('background','#183c7c');
    });

For IE (tried in 8 and 9), the last row of the script does not work - the background of button itself is not changed. For Firefox and Chrome it works fine.


Solution

  • It is working for me under IE9: http://jsfiddle.net/EWUeP/

    html:

    <div id="divy"></div> 
    

    css:

    div{
        width:300px;
        height: 300px;
        background-color: #eee000;
    }
    

    js:

    var d = document.id('divy');
    d.setStyle('background','#183c7c');
    

    But nevertheless if you want only to change bg color - call the correct css: d.setStyle('background-color','red'); background rule is the global rule for all background css types [color url position repeat etc..]