Alex
Alex

Reputation: 68074

jQuery - select a element with a certain attribute from a list of elements

I have a list of elements, in a "that" variable. How can I find a element with a specific attribute inside these?

(function( $ ) {
  $.fn.blah = function(){
    var that = this;
    return this.each(function(){
       $(this).bind('change', function(){
           $("[name]", that).dostuff(); // <- doesn't seem to work

           return true;
        }).change();

   });
 };

})(jQuery);

Upvotes: 0

Views: 2181

Answers (3)

Vivek
Vivek

Reputation: 11028

you can also use :contains

$(that).contains("[name]").dostuff();

Upvotes: 0

FeRtoll
FeRtoll

Reputation: 1267

Will this help?

var found=$(that).find("thingyousearching");

Upvotes: 1

jAndy
jAndy

Reputation: 236202

The .filter()help method should do it:

$(that).filter('[name]').dostuff();

Upvotes: 3

Related Questions