Since jQuery relies heavily on XPath , and XPath does not support the choice of substitution attributes, this is impossible without the overhead of hoping to avoid it.
It is always possible to create your own selector to keep it clean:
//adds the :dataValidate selector $.extend($.expr[':'],{ dataValidate: function(obj){ var i,dataAttrs=$(obj).data() for (i in dataAttrs) { if (i.substr(0,8)=='validate') return true; } return false; } })
This will allow you to use: dataValidate in your regular jQuery selectors:
$(".element:dataValidate .etc")
JSFiddle work: http://jsfiddle.net/rZXZ3/
source share