Here,
var data = '
<table align="left" border="1" cellpadding="1" cellspacing="1" style="width: 100%;">
<tbody>
<tr>
<td>
<textarea cols="80" id="editor" name="editor" rows="10">This is my textarea to be replaced with Editor.</textarea>
</td>
</tr>
<tr>
<td colspan="2">© 2016 Vishmay Shah</td>
</tr>
</tbody>
</table>
<p> </p>'
I want to update the editor's id to editor1 using jquery within data variable
I can access it using
$('#editor', Data)[0].id=$('#editor', Data)[0].id+'1';
but I want to save updated HTML in the data variable back.
UPDATE
There will be multiple editors with the same id editor.
Actually, I want to make it unique by appending index.
That is editor0,editor1,..., replace function will replace all editor, so it will not help
var editors = $('#editor', Data);
for (var i = 0; i < editors.length; i++) {
var subeditor = editors[i].id + i;
editors[i].id = subeditor;
}
idof element should be unique in document. See developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/idclassNameand replacement would not be necessary ? Access element using bracket notation on DOM elementelement[0],element[1]or jQuery.eq(); e.g;$(".element").eq(0),$(".element").eq(1)to return same results as mutlipleids$("#element0"),$("#element1")?