Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html lang="en">
<body>
<div id="123"></div>
<div id="oneTwoThree"></div>
<div id="0"></div>
<div id="zero"></body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script> 
(function($){
  
//James Padolsey filter extension
jQuery.expr[':'].regex = function(elem, index, match) {
    console.log(match)
    console.log(match[3].split(',').shift())
    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));
}
// Select div's where the id attribute contains numbers
console.log($('div:regex(id,[0-9])').length); // Alerts "2"
// Select div's where the id attribute contains the string "Two"
console.log($('div:regex(id, Two)').length); // Alerts "1"
  
// Select all NON block-level DIVs:
$('div:not(:regex(css:display, ^block$))'); 
})(jQuery);
</script>
</body>
</html>
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers