2011-11-23 71 views

回答

6

嘗試:

$("input").each(function() { 
    $(this).addClass($(this).attr("name")); 
}); 
+0

是的,效果很好,謝謝! –

+1

可能需要在其中添加一個.replace(/ _/g,' - '),以將下劃線轉換爲破折號,如同他的例子。否則看起來不錯。 –

相關問題