JQuery add and remove text box

I have this set of html codes that I want to add another input = "text" to increase the number of text fields when I press "+", but I'm not sure about the parent () function. parent (). Can anyone help?

here is my fetching jquery and html, sorry they look abit messy due to lack of css.

+3
source share
3 answers

I think it .append()will help you add elements and .remove()delete them (see example # 1 and example # 2 ).

, element.append(content); content element HTML ( ). element.remove(); element , , "" $("your_tr > td > label :last") ( your_tr).

+2

...

HTML:

<td colspan="2" id="tasklist">
    <label>
        <input type="text" value="Create a task for this iteration" size="75%" height="25px"/>
    </label>
</td>

JavaScript:

$("#tasklist").append('<input type="text" value="Create a task for this iteration" />');

  • . , , , . CSS, ,

? CSS:

label {
    display: none;
}
  • HTML- CSS

, .

+2

id , , .

+1

Source: https://habr.com/ru/post/1787904/


All Articles