Well, I guess I'm reading your question differently.
The way I read it, you want to create a custom selector that selects elements that have a given attribute name (or the start of that name).
If so, I think you'd need to iterate of the attributes
collection for each element.
DEMO: http://jsfiddle.net/GgmM7/
$.extend($.expr[':'],{
attrNameStart: function(el,i,props) {
var hasAttribute = false;
$.each( el.attributes, function(i,attr) {
if( attr.name.indexOf( props[3] ) !== -1 ) {
hasAttribute = true;
return false; // to halt the iteration
}
});
return hasAttribute;
}
});
$('img:attrNameStart(data-plugin)')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…