How to add javascript element inside a dynamically generated div tag

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.

Category:javascript Time:2017-12-05 Views:1

Related post

  • How to add an onclick function to dynamically created divs with pure Javascript 2014-09-30

    I currently am dynamically creating divs based on a XML file in one function, using the code below. var ftdImg = "<div class='single-img' id='" + pid + "'><a href='#'><img src='" + projHomeThumbURL + "'/></a><p>" + title

  • How to add a csrf_token to a dynamically generated form? 2011-04-06

    I have a dynamically generated form but I can't do anything with it since Django required a csrf_token in every POST form. My form is generated via: $("#results").append( '<form class="form-book-add" id="{0}" method="post" action="/books/add/">

  • How to put span element inside ActionLink MVC3? 2011-12-15

    How can I put a span element inside ActionLink BUT NOT WITH URL.ACTION? This: <li><span> @Ajax.ActionLink("LinkText", "ControllerName", new AjaxOptions { UpdateTargetId = "div", InsertionMode = InsertionMode.Replace, HttpMethod = "GET", L

  • How to add UI elements programatically to existing nib files 2012-02-07

    I wonder how to add UI elements programatically to existing nib files. If I create a view programatically in loadView method and I add code like the following, the label displays correctly. self.view = [[UIView alloc] initWithFrame:[UIScreen mainScre

  • how to add items to the spinner dynamically in android? 2010-01-29

    how to add items to the spinner dynamically in android? --------------Solutions------------- Spinner spinner = (Spinner)findViewById(R.id.mySpinner); ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.si

  • How to add javascript code to safari extension? 2010-08-25

    I create a safari extension , but I don't kown how to add javascript code to safari extension? --------------Solutions------------- A Safari extension is almost entirely Javascript. That's a bit of an oversimplification, but what kind of extension ha

  • How to add JavaScript in the content page that inherits from Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage 2010-12-01

    How to add JavaScript in the content page that inherits from Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage"? I also need to pass the client IDs of the dropdownlists present on the content in the JavaScript function. --------------Sol

  • How to Add an element to the source of a PagedCollectionView 2011-06-24

    in my Silverlight-4-App, I have a PagedCollectionView. Eventually, I want to add a new item to it's source. Unfortunately, I find no example how to do this. The AddNew() methode excepts no parameter. The CurrentAddItem is readonly. The SourceCollecti

  • How to pass a Javascript function in a dynamically created div 2011-10-19

    I want to pass a javascript function to a dynamically created div, like I am attempting below. If I replace the script string with an ordinary string this works, but is there a way to pass a JS script in createTextNode? newDiv = document.createElemen

  • How to add variable values inside pdo->query 2012-03-30

    I want to upgrade my current code which is constantly sql injected with PDO. Currently I'm stuck with using a variable inside a PDO query. If I have two arguments like this $rowsPerPage = 3; // by default we show first page $pageNum = 1; if (isset($_

  • Find checkbox values from Dynamically generated Divs in php using javascript 2010-01-25

    How to find checkbox values from Dynamically generated Divs in php using javascript? Here is my code, echo "<input type='text' name='chkID' id='chkID'> <div id='mainDiv'>"; while($rowset = mysql_fetch_array($result)) { echo "<div style

  • Can I add page numbers to a dynamically generated document using mime type application/msword? 2011-05-04

    How can I add page numbers to a dynamically generated document using mime type application/msword? --------------Solutions------------- Yes, you can add page numbers in dynamic generated documents. to get the codes open an new document enable page nu

  • How to set a CSSClass for a dynamically generated label? 2010-05-20

    How to set a CSSClass for a dynamically generated label in asp.net with C# --------------Solutions------------- Label lbl = new Label(); lbl.Text = "Hello World!"; lbl.CssClass = "red_and_bold"; When You create Label then set its CssClass property: h

  • Jquery: How to enlarge image on mouseover for dynamically generated images 2010-10-21

    How to enlarge image on mouseover for dynamically generated images from the database.I am using c# code to bind the images in the User Interface. I tried different Jquery plugins but most of them had compatibility issues with some browsers(IE 6). Kin

  • Selecting an element inside of the hovered "li" tag 2011-09-08

    I have a few <li> tags and I need to hide an element inside of the hovered <li>tag. The following code is not working, please let me know how can I get it worked... $(function(){ $("#deals ul li").hover(function(){ $(this:has(".transform"

  • How to dynamically generate DIV above an image 2012-02-08

    I have some scanned news paper and i want to dynamically generate div above the image. So when users click on specific DIV they are redirected to detail of that news. How is it possible ? One way of doing is to create Absoulute positioned div in fron

  • Pass dynamically generated div id's from Rails to javascript/coffeescript 2012-02-27

    I have a list of items for which I would like to reveal a more detailed description per item under the name of the item at the click of a button or link. For example, a very simple implementation would be using .toggle(). In Rails I have this for the

  • Accessing controls inside a dynamically generated control 2009-10-15

    I'm creating instances of various controls at runtime in the Page_Load method of another control. The dynamically generated controls are then added to a Placeholder. From inside the dynamically generated controls (in their own Page_Load method) I am

  • Set the Value of Dynamically Generated DIV input Fields 2011-03-30

    Dear Experts, I am following Mr.Steve Sanderson Example for working with variable length list, ASP.NET MVC 2-style. In my Scenario I have one text box in which a user scan through a barcode scanner and the value of scanned barcode will distributed in

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 1.524 (s). 14 q(s)