Which would have better performance?
$('input[data-confirm],a[data-confirm],button[data-confirm]');
or
$('[data-confirm]');
Obviously the $('[data-confirm]') version of the selector is more flexible, will it mean jQuery has to scan every single element in the page to see if it has the data-confirm attribute. Would I be better to use a class instead? I like using the data-confirm because I can put this in the value.
<input type="submit" data-confirm="Are you sure you want to do this sir?" />
Why not use a class AND the
data-confirm, this will allow you to be specific AND use thedata-confirmattribute to precisely target the exact element you want without having jquery look through everything else. This will make sure that regardless of browser your targeting will work faster. You can probably shave off a couple of nanoseconds off again if you use anidrather than a class.