[jQuery] Re: jquery code snippit improvement request

2007-10-18 Thread Yansky
It'll be more efficient if you store the elements you're going to manipulate into a variable. Also, since you're doing the same thing twice, you could make it into a function. e.g. $(document).ready(function() { var getTrs = $('tbody.bevker tr');

[jQuery] Re: jquery code snippit improvement request

2007-10-18 Thread Yansky
It'll be more efficient if you store the elements you're going to manipulate into a variable. Also, since you're doing the same thing twice, you could make it into a function. e.g. $(document).ready(function() { var getTrs = $('tbody.bevker tr');

[jQuery] Re: jquery code snippit improvement request

2007-10-18 Thread Frank Tudor
Jesus Christ?! Thanks for all the variations...AND explanations! Frank On 10/18/07, Michael Geary <[EMAIL PROTECTED]> wrote: > > > First, combine duplicate code into a single function: > > $(document).ready(function() { > zebra(); > $('th').click( zebra ); > }); > > function zebra() { >

[jQuery] Re: jquery code snippit improvement request

2007-10-18 Thread Frank Tudor
P.S. Here is what my final script looks like. After the below function example, I started to get lost in obscurity. $(document).ready(function() { zebra(); $('th').click( zebra ); function zebra() { $('tbody.bevker tr:odd').removeClass().addClass('row0 od

[jQuery] Re: jquery code snippit improvement request

2007-10-18 Thread Michael Geary
First, combine duplicate code into a single function: $(document).ready(function() { zebra(); $('th').click( zebra ); }); function zebra() { $('tbody.bevker tr:odd').removeClass(); $('tbody.bevker tr:even').removeClass(); $('tbody.bevker tr:odd').addClass('row0 odd'); $('