Tag Archives: jQuery

How to get an Element Starting with Class Name: the * and ^ JavaScript Selectors

You certainly know * and ^ as selectors in different programming languages. But you may have found some surprising (or frustrating) results while using them as JavaScript or jQuery selectors. Let’s say you want to access elements starting with a certain class name, for example, “fruit-“ in the following code: First, the syntax Your first reflex may be to try something like that: The correct syntax is: Then, the selectors: ^ vs * Using the ^ selector is correct, but its behavior is a bit too literal: it will get the very first element starting with the class name, or … Continue reading How to get an Element Starting with Class Name: the * and ^ JavaScript Selectors