Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
このような名前として配列を使用するフィールドがいくつかあります:
<select name="attr[address][#ID]"> <textarea name="address[#ID][cp]" placeholder="CP"></textarea>
jQueryを使用してunqiueIDを持つすべてのフィールドのサーム「#ID」を変更したいのですが、#IDを変更するために.attr()関数で正規表現のようなものを使用することは可能ですか?
よろしく、エイドリアン
#IDname属性内のすべての出現箇所を、次のように単調に増加する数に置き換えることができます。
#ID
var cntr = 1; $("[name*='#ID']").each(function() { this.name = this.name.replace(/#ID/, cntr++); });