我想使用jQuery重命名元素的id屬性。我需要符合以下條件:javascript正則表達式
- row_1
- row_2
- row_xx等
這是我到目前爲止有:
$('.form .newsCategories .row .itemWrap .itemTop .inputBtn').each(function(index){
$(this).attr("id", $(this).attr("id").replace($(this).attr("id").match(/\[row_[0-9]+\]/), "roww_"+index));
});
但這種失敗。我認爲我的登記證是錯誤的。請幫助 感謝
+1是在OP似乎做得使用attr很多(「ID」)不必要的地獄。 – 2011-02-15 21:38:02