Re: Parent Combinator / Parent pseudo-class

Sorry but it's not true... If you talk about the fact about the fact I 
abonnate myself on mouseover events, please give my a solution that can do I 
receive a JScript event any time something change for the specified element 
? It's not possible in JScript. So, yes, I must abonnate myself on the event 
manually. But there's no other possibility.... Yes, there's setInterval, but 
it's not really the good solution.

You can change it to (where ... are respectively the "before-selector 
selector" and "child-selector" in my sample).
Then, you can add a new css rule replace :with.... with ".-with-child-n".

        var cwc_count = 0;
        function createCSSWithChildRule(beforeSelector, childSelector, 
afterSelector, rule) {
            var count = cws_count; cws_count=cws_count+1;

            var sheet = document.createStyleSheet();
            sheet.cssText = beforeSelector + ".-with-child-"+count + " " + 
afterSelector + "{" + rule + "}";

            function update() {
                var divs = document.querySelectorAll(beforeSelector);
                var l=divs.length;
                for (var i=0; i<l; i++) {
                    if (divs[i].querySelector(childSelector)) {
                        divs[i].className="-with-child-"+count;
                    } else {
                        divs[i].className="";
                    }
                }
            }

            /* I don't have better solution if we must generalize in JScript 
*/
            setInterval(update, 500);
        }

    createCSSWithChildRule("body > div", "a:href", "a", "background: 
yellow")


Fremy 

Received on Wednesday, 23 July 2008 22:09:20 UTC