-2

I have this :

<div class="div1">
 <div class="div2">
  <div class="div3">
   <div>
    <input></input>
   </div>
   <input></input>
  </div>
 </div>
</div>

I want to get the input tag with JQuery and use Css.

I tried this :

   $('.div1 :input').css('background-color','blue');

but it doesn't work.

The problem is that there is an other input tag?

Edit : Sorry for not having detailed. I use a Date Control Form from Nintex and his input tag already has css by default. Problem solved!

Jayce
  • 535
  • 1
  • 6
  • 23

2 Answers2

0

As you have updated, via comment, that you just want the first input, use either the first() method on the search result, or use the :first selector. Examples of both below:

$('.div1 :input').first().css('background-color','blue');

http://jsfiddle.net/TrueBlueAussie/3LftU/2/

or

$('.div1 :input:first').css('background-color','blue');

http://jsfiddle.net/TrueBlueAussie/3LftU/3/

Ryan B
  • 3,338
  • 19
  • 35
Gone Coding
  • 88,305
  • 23
  • 172
  • 188
0

As you mentioned in your comment that a plugin has an input field whose css you want to change which already is their, you can do something like this

$('.div1 :input').style('background-color','blue','important');
V31
  • 7,480
  • 3
  • 24
  • 43