JSFiddle - React, Tailwind, and code Playground

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<p>one</p>
<p id="two">two</p>
<p>three</p>
<p class="four">four</p>

JavaScript

$.extend($.expr[':'], {
   'hasAnAttr': function(elem, i, attr){      
     return elem.attributes.length;
   }
});


var pWithAttrs = $('p:hasAnAttr');

alert("found: " + pWithAttrs.length);