treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] jQuery: if tr row count?

  • Hi there!

    I'm working on something like this: http://jsfiddle.net/yGM3m/

    But it won't work. It's displaying the "before" and "after" dom manipulations on both tables, when I only want it on the second table.

    I think I'm close. Help?

  • i don't really understand what you want to achieve.

    for this:

    It's displaying the "before" and "after" dom manipulations on both tables, when I only want it on the second table.

    you can put different element id

    http://jsfiddle.net/yGM3m/1/

  • You had a couple of problems going on. For starters, you had two divs with the same ID, this is a big no no. In my example I have changed them to classes.

    Secondly, your comparison looked like this rowCount = 7 which will always return true. What you were looking for is either rowCount === 7 or rowCount >= 7.

    http://jsfiddle.net/yGM3m/2/

  • I also added an each() loop if you are going to have multiple dimension tables on a single page.

  • @mweldan - Sorry that I may have written my post incoherently. TheDoc has done what I needed. Thank you, though!

    @TheDoc - That's exactly what I was looking for. Actually, I added the two ID's on Jsfiddle, but the 2 tables won't be on the page at the same time. :) Thank you! I knew I was close, but the operators were off.