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 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2008
    Location
    NEW YOrk
    Posts
    18
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Styling with JS !!!??

    Hi all...

    Can someone tell me what is wrong with my script... is no changing the text color :O/

    <script type="text/javascript">

    function init() {

    if (!document.getElementById('txt').value = "Recipient's name").style.color = "#a3a3a3";

    }

    </script>


    Thank

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,147
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    Code:
    <input type ="text" size = "50" id = "txt" onblur = "init()">
    
    <script type="text/javascript">
    function init() {
    if (document.getElementById('txt').value != "Recipient's name") {
    document.getElementById("txt").style.color = "#a3a3a3";
    }
    }
    
    </script>
    Recipient's name is a literal string. OK?


    Outside a secondhand shop: WE EXCHANGE ANYTHING - BICYCLES, WASHING MACHINES, ETC. WHY NOT BRING YOUR WIFE ALONG AND GET A WONDERFUL BARGAIN?


  •  

    Posting Permissions

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