On my webpage, I have a div of the "editor" class, which I copy to a variable.
editorTemplate = $('.editor');
The DIV looks like this (simplified):
<div class="editor"> <div> Title: <span class="title" id="title"> the title goes here </span><br /> <select class="recording_list" id="recording_list"> <option value="1">Pos 1</option> <option value="2">Pos 2</option> ... </select> </div>
Later, I want to create a series from this div by adding it to the page:
$(editArea).append(editorTemplate);
So far so good.
But I want to change some attributes - for example, field identifiers, some text and the selected item in the selection field - before inserting the editor template on the page.
I can change the id of the edit template with
$(myEdit).attr("id", "edit" + nEditors);
But I do not know how to access the elements of the INNER template, for example. ID and text of the "title" field.
After the template is inserted on the page, I can say
$('#title').attr("id", "title" + nEditors); $('#title').html("the new text"); ...
Is it possible to make these changes BEFORE I embed the template on the page?
PaulS source share