tags:

views:

31

answers:

2

I have few texboxes, dropdown lists, etc.. They have their css classes. I want to select all elements of specific class(es) but NOT the last element from group of all classes.

<asp:TextBox ID="TextBox1" runat="server" CssClass="class1" ></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" CssClass="class2" ></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" CssClass="class2" ></asp:TextBox>

I want to select only TextBox1 and TextBox2, not TextBox3!

selector should be something like this

$("(.class1,.class1):not(:last)")

or something like

    $(".class1,.class1").filter(":not(:last)")

but of course none of it is working :)

any sugestions? tnx in advance!

+2  A: 

Looks like your second selector is incorrect. You were on the right track, try this:

$(".class1, .class2").filter(":not(:last)");
Zacho
Ah, the silent killer.
harpo
Happens to all of us!
Zacho
works for me...
Scott Evernden
WOW U ARE FAST!To be honest I don't see any difference except for space between class1, and class2, but what's more interesting is that the code I posted is working :) Your is working too. Could be I had a typo, that I accidently corrected when I posted the question :)I found another way myself. See below.Tnx anyway :)
100r
You did have a typo, the second selector. That is what my answer said. You were doing the right thing, but you were selecting the same class twice.
Zacho
oh I see, but my classes are not called that way in original code, and that was not the problem in the code. typo was on another place.or it wasn't :) I don't know any more. Case solved! Tnx once again!
100r
+1  A: 
$(".class1,.class2").slice(0,-1)

Slice ftw! :) I think it's faster, it just clips the last one, no filtering involved!

100r