Change the color of text and cursor in the input field

When the user clicks a button in the box below, the cursor and typed text are black. How can I make their color #DE2A00?

<div class="usernameformfield"><input tabindex="1" accesskey="u" name="username" type="text" maxlength="35" id="username" /></div> 
+5
source share
5 answers
<style>
#username {
    color: #DE2A00;
}
</style>

Or you can change the color when the user clicks on the field like this:

<script type=text/javascript src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js'></script>
<script type=text/javascript>
    $(document).ready(function() {
        $('#username').click(function(){
            $(this).css({'color': '#DE2A00'});
        });
    });
</script>

It depends on what you want, I would look at this link to start playing with some things:

w3schools

and

css-tricks

+1
source

Just use CSS:

#username{color:#000;} /* black when not with focus */
#username:focus{color:#de2a00;} /* green when input has focus - only affects this specific input */
+3
source

Java:

onfocus="this.style.background = '#DE2A00'" onblur="this.style.background = 'white'" 
0

:

input:focus { color: #DE2A00  }
0

, , .

 <input...type="text"...style="color: #DE2A00;"/></div> 
0

All Articles