Skip to content
Advertisement

How to change the element position?

In my browsers Firefox and Chrome I don’t get any errors or warnings. It’s just practice. I’m taking a course in javascript and Dynamic HTML. If anybody cares to look at my code and tell me what I’m doing wrong I’d appreciate it. There’s got to be something that I’m not getting right.

I want to create new divs as the page loads. These divs will appear as an ordered group that changes depending upon external data from a JSON file. I will need to do this with a for a loop because there are over 100 divs needed.

demo

HTML:

JavaScript

Advertisement

Answer

You can put this in the onclick event so it will be added into that element only like this :

<a onclick="addChildFilter(this)"
then
function addChildFilter(reed){}
and then
reed.parentElement.append(html);

This way it is adding to the place where add subgroup btn is present . The problem here now is that the html code is printed directly not the fields as you know jQuery you may find the problem as I am not good in jQuery (so used some JavaScript) . See if you can and find help from this answer.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement