I am after documentation on using wildcard or regular expressions (not sure on the exact terminology) with a jQuery selector.
I have looked for this myself but have been unable to find information on the syntax and how to use it. Does anyone know where the documentation for the syntax is?
EDIT: The attribute filters allow you to select based on patterns of an attribute value.
Add a jQuery function,
Then,
will select all span elements with text matches /Sent/.
will select all span elements with their classes match /tooltip.year/.
ids and classes are still attributes, so you can apply a regexp attribute filter to them if you select accordingly. Read more here: http://rosshawkins.net/archive/2011/10/14/jquery-wildcard-selectors-some-simple-examples.aspx
James Padolsey created a wonderful filter that allows regex to be used for selection.
Say you have the following
div
:Padolsey's
:regex
filter can select it like so:Also, check the official documentation on selectors.
You can use the
filter
function to apply more complicated regex matching. Here's an example which would just match the first three divs (live demo here):These can be helpful.
If you're finding by Contains then it'll be like this
If you're finding by Starts With then it'll be like this
If you're finding by Ends With then it'll be like this
If you want to select elements which id is not a given string
If you want to select elements which id contains a given word, delimited by spaces
If you want to select elements which id is equal to a given string or starting with that string followed by a hyphen