• 0

[jQuery] .find with multiple results.


Go to solution Solved by mollick2,

Question

Axel
var colspanstart = $(rowID).find("td[colspan]").attr("class");

 

The above works but it only lets me manage the first element it finds matching that criteria on the row.

 

If there are multiple colspans on that row, how would I select the second or third one for example?

 

Many thanks.

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
mollick2

Your gonna want to use the each function

var colspanstart = new Array()
$(rowID).find("td[colspan]").each( function() {
    colspanstart.push( this.attr("class") )
})
  • Like 2
Link to post
Share on other sites
  • 0
Axel

Brilliant! Many thanks.

Link to post
Share on other sites
  • 0
spacer

I prefer to use "rowID" as a selector constraint.

 

$('td[colspan]', rowID)

 

Then you can use the ":eq()" filter in your selector if you really only want the second or third td.

 

$('td[colspan]:eq(2)', rowId)
Link to post
Share on other sites
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.