Note that there are some explanatory texts on larger screens.

plurals
  1. POChanges made on td does not reflect on <a> its child node
    text
    copied!<p>I have this table:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;a href=""&gt;Choultry&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="" &gt;Vegetable verndors&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;a href="" &gt;Decorators&lt;/td&gt; &lt;td&gt;&lt;a href="" &gt;Handicrafts&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>and each td has background color white and <code>font-color:rgb(121,0,0)</code>. So when I mouseover each td I want the background color to change to rgb(121,0,0) and font-color to change to white. So it alll works fine as long as I don't include <code>&lt;a&gt;</code> element i.e hyperlink element. By default hyperlink element is blue so I assign it to be rgb(121,0,0). When I mouse over td and do my usual reversing of color i.e. background color:rgb(121,0,0) and <code>color:white</code> only the background color changes whereas font color does not change it remains rgb(121,0,0) making it invisible. Meaning the changes to td does not reflect its child nodes i.e. <code>&lt;a&gt;</code> in this case.</p> <pre><code>.textTable td a { color:rgb(121,0,0); } .textTable td:hover { background-color:rgb(121,0,0); color:white; } </code></pre> <p>These below are diff ways i tried:</p> <p>1> </p> <pre><code>$(".textTable td").mouseenter(function(){$(".textTable td a").css("color","white");}); $(".textTable td").mouseleave(function(){$(".textTable td a").css("color","rgb(121,0,0)");}); </code></pre> <p>here the problem is it will make all elements inside .textTable td, that is quite obvious.</p> <p>2></p> <pre><code>.textTable td:hover { .textTable td a { color:white; } background-color:rgb(121,0,0); color:white; } </code></pre> <p>This was totally stupid.</p> <p>I know to have a complex code to solve this problem but is there any solution which is very simple so that even child nodes have the changes on their parents reflected?</p> <p>something like</p> <pre><code> $(".textTable td").mouseenter(function(){$(".textTable td a").css("color","white");}); $(".textTable td").mouseleave(function(){$(this).childNodes[0].css("color","rgb(121,0,0)");}); </code></pre>
 

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