Change color of textbox in javscript
How to change color of textbox(some part of string only, not entire text in textbox) in javascript?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hemant KumarPosted Oct 18, 2011, 7:57 AM
You can use CSS and some JavaScript to accomplish that. First, set the waiting text color and background color using CSS. Then, from the onload tag, have some JavaScript change the colors again:
It may be easier to move the JavaScript to a separate function, so you're not cluttering up the tag too much, but I'll leave that up to you.
The code in the onload event changes the color (of the text) and the background color properties of the style object. This style object belongs, in this example, to the text box.
TulasiPosted Oct 18, 2011, 7:39 AM
i have a textbox with content 'aaa@bbb@ccc'
what i need is , i want to change color of symbol( ' @') in textbox using Javascript
Hemant KumarPosted Oct 18, 2011, 7:33 AM
If you really need it your way, then do the following:
Replace
#textboxidwith the desired selector, and color with the desired color.Note the following does the same for one property: