0

jQuery selectors on custom data attributes using HTML5

var microsofts = $("ul[data-group='Companies']").find(" li[data-company='Microsoft']"); //Get all elements with data-company="Microsoft" below "Companies"

console.log(microsofts.html()); // Microsoft
<ul data-group="Companies">
  <li data-company="Microsoft">Microsoft</li>
  <li data-company="Google">Google</li>
  <li data-company="Facebook">Facebook</li>
</ul>
RUN
add comment
Suggest a different solution or add another example