Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation How to compare text box's background color

    Hi
    How to compare background color of a textbox ,
    i have tried the following code but it is not working

    if(document.getElementById('myName').style.backgroundColor=='rgb(254,204,204)')
    and
    if(document.getElementById('myName').style.backgroundColor=="#fcc")

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Why not pop up an alert, and see what's in there? Never assume a value is what you think it should be.

    Code:
    javascript:alert(document.getElementById('myName').style.backgroundColor);
    Just dump it in the address bar, and hit enter.

    This might help. A little dated, but still useful.

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks i have tried and it is working


  •  

    Posting Permissions

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