Lets say I have an element like this:
<input id="options_14_text" type="text" onchange="something()" name="options[14]" value="">
How could I change its id to options_15_text for example using Prototype?
Thanks!
You can select the element and then change its id
property:
$("options_14_text").id = "options_15_text";
Or you could use writeAttribute
:
$("options_14_text").writeAttribute("id", "options_15_text");
Here's a working example. Inspect the DOM to see that the id
value has changed.