jQuery Set Child CSS Attribute Problem
Posted
by Jascha
on Stack Overflow
See other posts from Stack Overflow
or by Jascha
Published on 2010-05-31T15:33:38Z
Indexed on
2010/05/31
15:43 UTC
Read the original article
Hit count: 319
I have a child element of a div named "bob" that's class is '.divTitle'
<div id="bob">
<div class="divTitle">
<a href="#">
<h1>Title</h1>
</a>
</div>
</div>
I am trying to set the background color of "divTitle" to red but for the life of me can't get this to work. Right now I am trying two things...
$('#bob').children('.divTitle')[0].css('background-color', '#0f0'); // assuming children is returning an array...
and
$('#bob').children('.divTitle').css('background-color', '#0f0');
neither with any success... can anyone tell me what I am missing here? Do I have to go deeper than ".children"?
© Stack Overflow or respective owner