Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, there are various methods to retrieve descendant elements (such as <a href="https://developer.mozilla.org/en/DOM/element.getElementsByTagName" rel="nofollow"><code>getElementsByTagName</code></a>), but <a href="https://developer.mozilla.org/en/DOM/document.getElementById" rel="nofollow"><code>getElementById</code></a> does not accept a CSS selector. The reason why <code>[...].children.style</code> does not work is that <a href="https://developer.mozilla.org/en/DOM/Element.children" rel="nofollow"><code>.children</code></a> returns a <code>NodeList</code>, i.e. a <em>collection</em> of nodes. You'd have to iterate over it or access it with the index of the node you want.</p> <p>I suggest a different, easier approach:</p> <p>Create a CSS rule for the color, using a class:</p> <pre class="lang-css prettyprint-override"><code>.today h3 { color: #DB35B0; } </code></pre> <p>Add that class to the current day:</p> <pre><code>var days = ['Sunday', 'Monday', ..., 'Saturday'], now = new Date(), today = now.getDay(); document.getElementById(days[today]).className += ' today'; </code></pre> <p>This is less code and you can make changes to the style more easily.</p> <p><strong>Edit:</strong> I just saw that you tagged the question with jQuery. In that case, you can replace the last line with:</p> <pre><code>$('#' + today).addClass('today'); </code></pre> <p>In contrast to DOM interface methods such as <code>getElementById</code> or <code>getElementsByTagName</code>, jQuery uses CSS selectors to get references to elements. You should have a look at the <a href="http://api.jquery.com/" rel="nofollow">documentation</a> if you intend to use it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload