Puwhae
Puwhae

Reputation: 67

Change a specific input's css elements

<div id="right-side-panel">
        <span>UserName:<br />
        <input id="txtUserName" type="text" />
        </span>
        <br />
        <span>Password:<br />
        <input id="txtPassword" type="password" />
        </span>
        <br />        
        <input id="btnLogin" type="button" value="Login" />
        </div>

How can I reach this txtUserName from css file? I want to change textBox's things.

#right-side-panel .. then?

Thanks in advance

Upvotes: 0

Views: 483

Answers (3)

MCSI
MCSI

Reputation: 2904

for example: in css #txtUserName { color:black; }

in jQuery $('#txtUserName').css('color', 'black');

Upvotes: 0

Simone
Simone

Reputation: 21292

The W3C defines IDs as "a unique identifiers to an element", so you just need #txtUserName in order to match that <input>.

Upvotes: 1

El Guapo
El Guapo

Reputation: 5781

why can't you just do: input#txtUserName?

Upvotes: 0

Related Questions