www.webdeveloper.com
Results 1 to 3 of 3

Thread: Please help -- IE vs FF

Hybrid View

  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Please help -- IE vs FF

    Changing a background color. This works in FF:

    Code:
    document.getElementById("box"+c+"cell").style.backgroundColor = "#CAFF89";
    It does not work in IE. Instead, this works in IE:

    Code:
    box1cell.style.backgroundColor = "#CAFF89";
    My question is how do I determine the DOM element's name dynamically in IE? (e.g. box1cell vs ("box"+c+"cell")

    Can I do it without jquery? Thus far I've been unable to get jquery successfully working.

  2. #2
    Join Date
    Nov 2010
    Posts
    1,082
    which version of IE?

    this works fine in 8 (and I would be surprised if it doesn't in anything >5)

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    
    </head>
    <body>
    <div style="height:100px; width:100px; background-color:red; "id="box1cell" onclick="change()"></div>
    <input type="button" value="change" onclick="change()"/>
    <script type="text/javascript">
    
    
    function change(){
    var c=1;
    document.getElementById("box"+c+"cell").style.backgroundColor = "#CAFF89";
    }
    </script>
    
    </body>
    </html>

  3. #3
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    The first line should work, there must be something wrong with the associated markup, which you should show.
    Also show how your code is being called.
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles