Still not the best solution, but a bit more efficient:
$("li").removeClass("even odd").each(function(i){
$(this).addClass(i%2 ? 'odd' : 'even')
});
On Jun 5, 8:40 pm, MorningZ wrote:
> // delete
> then
>
> $("li").removeClass("even").removeClass("odd")
> .filter(":odd").addClass("odd")
assuming you're always deleting one element at at a time (or in odd
quantities, hehe), how about
$(deleted_element).nextAll().toggleClass('odd').toggleClass('even');
(would be shorter if toggleClass could take multiple classes)
On Jun 5, 4:57 pm, "Dave Maharaj :: WidePixels.com"
wrote:
> I hav
Thanks everyone for your assistance.
Greatly appreciated.
Dave
-Original Message-
From: RobG [mailto:robg...@gmail.com]
Sent: June-06-09 11:27 AM
To: jQuery (English)
Subject: [jQuery] Re: Even Odd Rows
On Jun 6, 11:25 pm, Karl Swedberg wrote:
> You can make that first lin
here's something i put together
var iseven = 0; // a normal 1, 0 switch
var limit = 34; // maximum limit
$("body").prepend('<\/ul>'); // i want to do this as a list
for(var i = 0; i < limit; i++) {
if(iseven = 0) {
// if odd
$(".test").append('Odd<\/li>')
iseven = 1;
} else {
// if even
$(".test
On Jun 6, 11:25 pm, Karl Swedberg wrote:
> You can make that first line a bit more compact:
>
> $("li").removeClass("even odd")
It's still very inefficient. All that is required is for the LIs
below the deleted one to have their class swapped from odd to even and
vice versa.
--
Rob
You can make that first line a bit more compact:
$("li").removeClass("even odd")
--Karl
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Jun 5, 2009, at 11:40 PM, MorningZ wrote:
// delete
then
$("li").removeClass("even").removeClass("odd")
.filter(":odd")
// delete
then
$("li").removeClass("even").removeClass("odd")
.filter(":odd").addClass("odd")
.end()
.filter(":even").addClass("even");
On Jun 5, 7:57 pm, "Dave Maharaj :: WidePixels.com"
wrote:
> I have a li layout which have the even odd class applied to them. Each item
>
7 matches
Mail list logo