2012-03-08 62 views
0

each功能上的<a>標籤,但以我的ul的ID開頭。有沒有辦法在jQuery中選擇類似CSS堆棧的元素?

$('#ulID.li.a').each(function() { 
    //do stuff here. 
}); 

這是否接近我將如何做到這一點?

+3

你不清楚你想要做什麼,你能澄清嗎? – 2012-03-08 21:33:38

+0

這樣也許? http://stackoverflow.com/questions/1389005/jquery-wild-card-character – 2012-03-08 21:33:54

回答

0

嘗試刪除就像這樣。 「」:

$('#ulID li a').each(function() { 
//do stuff here.}); 
0

是的,像在CSS中一樣使用空格。

$("#ulID li a").each(... 
1

我猜這就是你要找的內容:

$('#ulID > li > a').each(function() { 
    //do stuff here. 
}); 

或者,也許這就足夠了:

$('#ulID a').each(function() { 
    //do stuff here. 
}); 
0

給它一個類名而不是id。這樣你可以申請所有。

相關問題