jQuery attribute selectors: How to query for an attribute with a custom namespace jQuery attribute selectors: How to query for an attribute with a custom namespace jquery jquery

jQuery attribute selectors: How to query for an attribute with a custom namespace


jQuery does not support custom namespaces directly, but you can find the divs you are looking for by using filter function.

// find all divs that have custom:attr$('div').filter(function() { return $(this).attr('custom:attr'); }).each(function() {  // matched a div with custom::attr  $(this).html('I was found.');});


This works in some conditions:

$("div[custom\\:attr]")

However, for a more advanced method, see this XML Namespace jQuery plug-in


the syntax for matching by attribute is:

$("div[customattr=bla]") matches div customattr="bla"

$("[customattr]") matches all tags with the attribute "customattr"

with namespace attributes like 'custom:attr' its not working

Here you can find a good overview.