Adrian M.
Adrian M.

Reputation: 7423

jQuery appendTo all elements except last one

I am trying to append all elements of the same class "td.top" except last one to another place, but I can't figure out how is this possible.. Any ideas are welcomed, I am kind of stuck.. Thank you for any input. This is the code I have now:

$(document).ready(function() {
if ( $(window).width() < 960) {

$("td.top").appendTo("ul.sub");

} else {

//something else

}
});

Upvotes: 1

Views: 597

Answers (1)

marteljn
marteljn

Reputation: 6516

How about:

$("td.top").not(":last").appendTo("ul.sub");

Upvotes: 5

Related Questions