Snippet

Sélecteur de données jQuery

5 réponses de la communauté

$('div[data-key=value]');
$('[data-attribute="value"]');
<a data-id="123">link</a>


var id = $(this).data("id"); // Will set id to 123
$("ul[data-group='Companies'] li[data-company='Microsoft']") //Get all elements with data-company="Microsoft" below "Companies"

$("ul[data-group='Companies'] li:not([data-company='Microsoft'])") //get all elements with data-company!="Microsoft" below "Companies"
$('*[data-id="your_id"]');