2012-07-09 50 views
1

我在動態類名稱循環內生成一些html表。這些類的樣子:jQuery的選擇類與類似的名稱

<tr class="method_11"> 
<tr class="method_12"> 
<tr class="method_13"> 

有沒有辦法只使用他們的共同部分

$('.method_options_1'+' ')選擇上述所有類的?

回答

3
$('tr[class^="method_"]') 

這將選擇元素,其中屬性 「類」 開始與 「method_」,符合你的標準。

+0

@ tao.hong沒問題 - 很高興幫助。 – 2012-07-09 15:36:29