How to add the previous list in the drop-down list

I use the following form constructor ( http://dontlink.me/formbuilder/ ) and make a lot of changes to it to work the way I want.

One of the things I want to do is when you add a new form field, I want this form field to be placed at the bottom of the list ... At the moment they are placed at the top.

This is the code that adds a new li to the list ... I simplified it to the part that actually adds ...

var result = '<li>The new form field code goes here....</li>'; var into = $("#form_builder_panel ol"); $(into).prepend(result); 

For some reason, by default they add the "li" tag to the code and give it the "last-child" class.

 <div id="form_builder_panel"> <form method="post" action="preview.php" class="fancy"> <fieldset class='sml'> <legend>Built Form</legend> <ol> <li class="last-child"></li> </ol> </fieldset> 

Now I tried to change this third line of code to the following:

 $(into).append(result); 

But then it puts li 'last-child' at the top and the script stops working ...

So my question is: how can I do this so that it adds a new list li to the list, but adds it over the personal name 'last-child'?

Hope I make sense :)

+4
source share
2 answers

What about

before function

Insert content in front of each of the matched elements.

 $(".last-child").before(result); 

If you want to add it as the last li each time, then remove the "last-child" class from li and use : last -child , for example

 $(".sml li:last-child").after ( result ); 
+6
source

works $(into).innerHtml = result; ?

0
source

All Articles