by
168 12
4
7
313k
0
Top 1% !
Popular
Famous
Pearl of Wisdom
Tagged
Specified
OpenSource
Popularity: 3438th place

Published on:

LanguageJavascript
LicenseMIT_X11
TechnologyJQuery

CSS Regex Selector Extension For jQuery

Using this extension enables regular expresions css selectors in jQuery
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/303124/CSS-Regex-Selector-Extension-For-jQuery?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
/** * CSS Regex Selector Extension For jQuery * */ jQuery.expr[':'].regex = function(elem, index, match) { var matchParams = match[3].split(','), validLabels = /^(data|css):/, attr = { method: matchParams[0].match(validLabels) ? matchParams[0].split(':')[0] : 'attr', property: matchParams.shift().replace(validLabels,'') }, regexFlags = 'ig', regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags); return regex.test(jQuery(elem)[attr.method](attr.property)); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus