JQuery attribute task for CSS child attributes
I have a div child named "bob", this 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 the "divTitle" to red, but for me life cannot make this work. I'm trying two things right now ...
$('#bob').children('.divTitle')[0].css('background-color', '#0f0'); // assuming children is returning an array...
and
$('#bob').children('.divTitle').css('background-color', '#0f0');
with no success ... can anyone tell me what i'm missing here? Should I go deeper than the "children"?
EDIT, , . div , . , div , , , ... Keltex .
+3
3
. - .
: , / ?
<head>
...
<script>
$(document).ready(function() {
$('#bob .divTitle').css('background-color', '#0f0');
});
</script>
</head>
...
, script DOM.
...
<div id="bob">
<div class="divTitle">
<a href="#">
<h1>Title</h1>
</a>
</div>
</div>
<script>
$('#bob .divTitle').css('background-color', '#0f0');
</script>
...
+2