1
如何在選擇器中按ID和下一個選擇tr?在表格中,選擇tr#myId和nextone
到目前爲止:
var item = $('tr#CP') /* Selects the item */
var nextitem = $('tr#CP').next('tr') /* selects next*/
,但我怎麼能同時選擇?
如何在選擇器中按ID和下一個選擇tr?在表格中,選擇tr#myId和nextone
到目前爲止:
var item = $('tr#CP') /* Selects the item */
var nextitem = $('tr#CP').next('tr') /* selects next*/
,但我怎麼能同時選擇?
$("#CP").next('tr').addBack();
的tr#
是沒有必要的,因爲只能有一個#CP
反正。 .addBack
「將原始選擇器添加回集合」。
我們怎麼沒有想到這個?
var bothitem = $('tr#CP,tr#CP + tr');
有趣..
有趣的是,我還沒有聽說過回加的,感謝您的信息:) – James 2013-02-28 15:12:22
'.addBack()'曾經被稱爲'.andSelf()';新的名字更清晰一點。 – Blazemonger 2013-02-28 15:16:46
非常有趣!這個問題並不像我想的那樣愚蠢! – 2013-02-28 15:25:30