Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Removing row from table

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First i am changing the background color of a row in a table on mouse click. Then If I press remove button i need to remove all the rows which has background color. can anyone help me to do this?
 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe in jQuery it would look something like...



Check into it. Its very nice

www.jquery.com

thanks
Bryce
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Loop through all of the table rows and remove the class.

var rows = document.getElementById("yorTableId").getElementsByTagName("tr");
for(var i=0;i<rows.length;i++){
rows[i].style.className = "normal";
}

Eric
[ January 21, 2008: Message edited by: Eric Pascarello ]
 
Sheriff
Posts: 67745
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Small correction to jQuery example:
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My first idea was to code it as you have coded it. I use Visual jQuery 1.1 to look at the methods and how they are used. http://visualjquery.com/1.1.2.html

Now, I know that 1.2.2 is out but this should still apply. If you look under DOM -> Manipulation -> remove the example seems to show the way I coded it. Is it wrong on there? Is there a better quick reference out there than that site?

Thanks Bryce
 
Author
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Bear said'll work great! Keep in mind, however, that animating table changes is still quite a bit of black magic, because table rows can't smoothly and reliably change size. If you want to change the size of a table row, you'll probably need to wrap all of the TRs in individual DIVs, give the DIVs overflow: hidden, and then shrink the divs.

something like

where you have the following in your CSS:

[ January 21, 2008: Message edited by: Yehuda Katz ]
 
Bear Bibeault
Sheriff
Posts: 67745
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I should have said "alternative" rather than correction. My bad. There's no need to select all the tr's and then filter them rather than selecting only the target ones in the first place.
[ January 21, 2008: Message edited by: Bear Bibeault ]
 
Yehuda Katz
Author
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My comment above, just to be clear, only applies to *animating* table cells with slideUp or slideDown. That's because table cells can't get overflow: hidden and so can't animate smoothly.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic