I have this code:
$(document).ready(function() {
$form.find()
});
#second {
font-size: 20px;
color: green;
background: white;
text-align: center;
}
<form>
<div class="first" style="width: 301px; margin:5px 0 0 10px;">
<div id="second" style="font-size:18px; position: absolute; top: 8px; left: 5px; width: 300px; height: 42px;">Hello</div>
</div>
</form>
I want to select the div with id="second", in order to change the background to red. Is there any solution to do that using find().
The most important thing for me is to select that div using it's id.
jsFiddle
$(document).ready(function() {
$("form").find( "div#second" ).addClass('red');
});
CSS
.red{
background-color: red;
}
$(document).ready(function() {
$("form div").find( "div" ).css( 'background-color', 'black');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With