Add input field with jQuery -


i'm quite new jquery, still trying wrap head around how works.

i'm creating admin-panel admin can insert questions. not fixed amount, admin should able add or remove input-fields, admin can choose desired amount questions.

this how looks graphically: add-remove

and code:

            <div class="adinputfield90">             <input type="text" placeholder="insert question 1"> <span class="font-entypo icon-circled-cross adaddnextremove" aria-hidden="true"></span></input>             </div> 

the span class holds image, add-new input webfont.

how can work, can add infinite amounts of inputfields? should of cause make sure if theres 1 input can add, , not remove one.

all appreciated!

include in head section of page

<script> $(function(){    $('.adinputfield90 span').click(addtextbox);  });  function addtextbox(){   $('.adinputfield90').append('<input type="text" placeholder="insert question 1"> <span class="font-entypo icon-circled-cross adaddnextremove" aria-hidden="true"></span></input>');   $('.adinputfield90 span').unbind('click');   $('.adinputfield90 span').click(addtextbox); } </script> 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -