I am trying to modify this project to show me some dates with colors, but i dont know how should i edit a specific element, lets say with id="3" what is inside the div with id ="March". Until now in all my atempts i only succeded coloring all divs with id="3". So my question is how do i modify the proprietes of an element with id="3" && id="March"?
To target a div within a div do this:
<div id="3">
<div id="March"></div>
</div>
#3 #March {
color: purple;
}
Also try to use reasonable variable names in a camelCase naming convention.
Just use the DOM API for this. In your case:
let march = document.getElementById('March')
let third_of_march = document.getElementById('3')
A small tip: IDs should be unique. The DOM API only returns one element. You should use classes in your use-case. This would make it even more simple.
let every_third_day = document.getElementsByClassName('3')
You can simply iterate over all elements and do whatever you want to do.
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