How to do a wildcard element name match with “querySelector()” or “querySelectorAll()” in JavaScript?

[id^=’someId’] will match all ids starting with someId. [id$=’someId’] will match all ids ending with someId. [id*=’someId’] will match all ids containing someId. If you’re looking for the name attribute just substitute id with name. If you’re talking about the tag name of the element I don’t believe there is a way using querySelector

How to create a collapsing tree table in html/css/js?

SlickGrid has this functionality, see the tree demo. If you want to build your own, here is an example (jsFiddle demo): Build your table with a data-depth attribute to indicate the depth of the item in the tree (the levelX CSS classes are just for styling indentation):  <table id=”mytable”> <tr data-depth=”0″ class=”collapse level0″> <td><span class=”toggle … Read more

CSS combinator precedence?

No, there is no notion of precedence in combinators. However, there is a notion of order of elements in a complex selector. Any complex selector can be read in any direction that makes sense to you, but this does not imply that combinators are distributive or commutative, as they indicate a relationship between two elements, … Read more

Targeting position:sticky elements that are currently in a ‘stuck’ state

There is currently no selector that is being proposed for elements that are currently ‘stuck’. The Postioned Layout module where position: sticky is defined does not mention any such selector either. Feature requests for CSS can be posted to the www-style mailing list. I believe a :stuck pseudo-class makes more sense than a ::stuck pseudo-element, … Read more

CSS selector involving pseudo class first-child and dropcap

If you’re OK with using CSS3 selectors, try using these (grouped together): /* Select the first child if it’s not a .quote */ article > p:not(.quote):first-child:first-letter, /* Or, if the first child is a .quote, select the following one instead */ article > p.quote:first-child + p:first-letter { float: left; font-family: Georgia, serif; font-size: 360%; line-height: … Read more

How to retrieve partial text from a text node using Selenium and Python

To print text … you have to induce WebDriverWait for the visibility_of_element_located() and you can use either of the following Locator Strategies: Using CSS_SELECTOR, childNodes and strip(): print(driver.execute_script(‘return arguments[0].firstChild.textContent;’, WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, “a.call_recipe[href^=’/recipes’]”)))).strip()) Using XPATH, get_attribute() and splitlines(): print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, “//a[@class=”call_recipe” and starts-with(@href, ‘/recipes’)]”))).get_attribute(“innerHTML”).splitlines()[1]) Note : You have to add the following imports : from … Read more