How to use a regular expression in querySelectorAll?

You can’t really use a regular expression in a selector but CSS selectors are powerful enough for your need with a “starts with” syntax inspired by regexes. You can use a substring matching attribute selectors : link[type^=service] Reads “Nodes of type link with an attribute type starting with “service” From the formal specification: [att^=val] Represents … Read more

Changing CSS pseudo-element styles via JavaScript [duplicate]

If you’re comfortable with some graceful degradation in older browsers you can use CSS Vars. Definitely the easiest of the methods I’ve seen here and elsewhere. So in your CSS you can write: #editor { –scrollbar-background: #ccc; } #editor::-webkit-scrollbar-thumb:vertical { /* Fallback */ background-color: #ccc; /* Dynamic value */ background-color: var(–scrollbar-background); } Then in your … Read more

Using querySelector with IDs that are numbers

It is valid, but requires some special handling. From here: http://mathiasbynens.be/notes/css-escapes Leading digits If the first character of an identifier is numeric, you’ll need to escape it based on its Unicode code point. For example, the code point for the character 1 is U+0031, so you would escape it as \000031 or \31 . Basically, … Read more

“querySelectorAll()” with multiple conditions in JavaScript

Is it possible to make a search by querySelectorAll using multiple unrelated conditions? Yes, because querySelectorAll accepts full CSS selectors, and CSS has the concept of selector groups, which lets you specify more than one unrelated selector. For instance: var list = document.querySelectorAll(“form, p, legend”); …will return a list containing any element that is a … Read more

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

Can I use a regular expression in querySelectorAll?

You can’t really use a regular expression in a selector but CSS selectors are powerful enough for your need with a “starts with” syntax inspired by regexes. You can use a substring matching attribute selectors : link[type^=service] Reads “Nodes of type link with an attribute type starting with “service” From the formal specification: [att^=val] Represents … Read more

Using querySelectorAll(). Is the result returned by the method ordered?

The returned node list is ordered. A quick test proved it: document.querySelectorAll(“body, head”)[0]; //Returned [object HTMLHeadElement] Obviously, the <head> tag appears before <body> in a HTML document. The first element of the NodeList is also a <head> element, even if the selector shows body before `head. From http://www.w3.org/TR/selectors-api/#queryselectorall: The querySelectorAll() method on the NodeSelector interface … Read more

How to remove elements that were fetched using querySelectorAll?

Yes, you’re almost right. .querySelectorAll returns a frozen NodeList. You need to iterate it and do things. Array.prototype.forEach.call( element, function( node ) { node.parentNode.removeChild( node ); }); Even if you only got one result, you would need to access it via index, like elements[0].parentNode.removeChild(elements[0]); If you only want to query for one element, use .querySelector … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)