css selectors - What is the alternative to CSS-selecting an ancestor -


css(3) has descendent selectors, e.g. td em {color: red};, no ancestor selector, apparently.

so, should instead of td {border: 1pt solid red} em; ? i.e., how can set style on ancestors of (x)html element?

note:

  • javascript not relevant workaround, xpath'y might be.

you can wait css4 selectors implemented, do

td! em {     border: 1pt solid red; } 

see http://dev.w3.org/csswg/selectors4/.

or...

var xpathresult = document.evaluate("//td[.//em]",      document, null, xpathresult.any_type, null);  while (e=xpathresult.iteratenext()){     e.classlist.add("border"); } 

see https://developer.mozilla.org/en-us/docs/dom/document.evaluate. normal browser support caveats apply.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -