I am dynamically generating a div tag after the page loads. this is the script which i am using. i want to insert an element inside a div element. but it is getting placed outside.
var newTag = 0
$("#addNewTag").on('click', '', function () {
andTag = andTag + 1
var stringTemplate = "<div id=\"newTag" + newTag + "\"><input type=\"button\" value=\"[+]\" id=\"addfield\"></div>";
var parentID = "#" + $(this).parent().attr('id');
$(parentID).append(stringTemplate);
$("#signatureContent").each(function () {
var content = $(this);
angular.element(document).injector().invoke(function ($compile) {
var scope = angular.element(content).scope();
$compile(content)(scope);
});
});
});
$("body").on('click', '#addfield', function () {
sfieldnum = sfieldnum + 1;
var stringMatchTemplate = "some dynamic content";
var parentID = "#" + $(this).parent().attr('id');
$(parentID).append(stringMatchTemplate);
$("#signatureContent").each(function () {
var content = $(this);
angular.element(document).injector().invoke(function ($compile) {
var scope = angular.element(content).scope();
$compile(content)(scope);
});
});
});
I want the HTML to be something like this after the first script
<new>
[+]
</new>
When i press [+] i want to insert a text box .
BUt what i am getting is something like this..
<new>
[+]
</new>
{text box appears here instead of appearing inside the new tag.}
what am i doing wrong here ?
Thanks.