Reputation: 10030
For those who know JQuery - must be effort less question -
I'd like to get the elemenet which is the last child of another element (of type 'input' that I know its ID ('myID').
What is the correct query:
I tried:
$("input:last-child", $("#myID"));
$("#myID input:last-child")
But it didn't work
Upvotes: 3
Views: 14257
Reputation: 11028
You can use last method too. Something like this:
$("#myID").last();
But make sure that you have jquery 1.4.X. While :last matches only a single element, :last-child can match more than one: one for each parent.
and i think what you have write will work in this way..
$("#myID input:last-child").val();
Upvotes: 0
Reputation: 26514
Try:
$("#myID input:last") //for the last
$("#myID input:first") //for the first
Upvotes: 7