I am using jquery-1.11.1 and I try to use the :data selector, described on
https://api.jqueryui.com/data-selector/
trying to find all elements having a certain key like this:
var elements = $(':data(kendoMobileScroller)');
but all I get is an error saying:
Error: Syntax error, unrecognized expression: unsupported pseudo: data
Shouldn´t there be such a selector?
You need to include jQuery UI in order to get :data
pseudo selector working, e.g:
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
Or just extend jQuery:
$.extend( $.expr[ ":" ], {
data: $.expr.createPseudo ?
$.expr.createPseudo(function( dataName ) {
return function( elem ) {
return !!$.data( elem, dataName );
};
}) :
// support: jQuery <1.8
function( elem, i, match ) {
return !!$.data( elem, match[ 3 ] );
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With