Cannot use data-foo atribute as a selector
I am using the jQuery UI Tooltip. by default this uses the contents of the title attribute to populate the tooltip. It is straightforward to change this to use the contents of the HTLM5 data attribute instead. However, I cannot find any way of using the data attribute as a selector so that the tooltips only operate on elements that have the data-foo attribute.
According to the API spec, the tooltip is attached to elements by the code:
$( ".selector" ).tooltip();
I have tried various permutations such as:
$( ".data-foo" ), $( "data-foo" ), $( data("foo")),
$( 'data("foo")'),
$( '.data("foo")'),
etc,
but none of them work.
Of course, I could add a class and use that as a selector, but it seems absurd not to be able to use the data-foo attribute as a selector in some form. Can anyone shed some light on this?