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

前端 未结 5 1541
一整个雨季
一整个雨季 2020-12-24 11:46

Suppose I have a simple XHTML document that uses a custom namespace for attributes:


            


        
5条回答
  •  悲&欢浪女
    2020-12-24 12:15

    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.');
    });
    

提交回复
热议问题