I have two static div tags with a select tag and a text box inside, each with different IDs. When I clone the tag, it duplicates the same div tag in the DOM. How can I change the inner elements' tags?
Below is the code snippet:
<div id="masterGrade" style="border-style: solid; width: 200px">
<select id="selectGrade1">
<option value="grade1">Grade 1</option>
<option value="grade2">Grade 2</option>
<option value="grade3">Grade 3</option>
<option value="grade4">Grade 4</option>
</select>
<input type="text" id="text1"/>
</div>
<div style="border-style: solid;width: 200px">
<select id="selectGrade2">
<option value="grade1">Grade 1</option>
<option value="grade2">Grade 2</option>
<option value="grade3">Grade 3</option>
<option value="grade4">Grade 4</option>
</select>
<input type="text" id="text2"/>
</div>
My JavaScript function:
$scope.addGrade = function() {
var div = document.getElementById('masterGrade'),
clone = div.cloneNode(true);
clone.id = "some_id";
document.body.appendChild(clone);
}
If you have any suggestions or solutions, please share them. Thank you!