MAC
MAC

Reputation: 6577

Adding one div element to the Parent div

I have one application, which allows users to enter multiple comments into multiple text boxes. Presently I am using the Ck editor tool. I have 4 divs which all are placed in a parent div. We call shift the position of child div up and down and also we can delete the div. When I try to delete the div, it goes and if the user clicks on the add, it should come.

My problem is when I am trying to add the new child div, it will not come under the existing remaining div. I have tried to use Append(), AppendTo(), Insert(), InsertAfter(), etc, but unfortunately with no luck. Can you guys please help me wash out this issue?

Here is one code snippet:

    var children = $('#editors').children(); // Editors is a Parent Div.
    var childrenCount = children.length;
            if (childrenCount == 1) {
                if (SectionName == 'Statement') {
                    $('#p0').insert("#p" + (children[0].id).toString());

Upvotes: 0

Views: 127

Answers (2)

Steven
Steven

Reputation: 1494

I don't understand exactly what you are trying to achieve, but maybe something like this might help

$("#p0").append($("#p" + (children[0].id).toString()).html());

Upvotes: 1

SethMW
SethMW

Reputation: 1082

If I am understanding the issue correctly, you should be able to do something like:

$("<div id='myNewlyAddedDiv'>Test</div>").appendTo("#editors");

That will append the new div after the one that is still in your parent div.

Upvotes: 1

Related Questions