Mehd S
Mehd S

Reputation: 583

Adding input in jQuery and problem adding several input with a click

Why after a click on add, adding several input together?
I want once times add input in each click on add.
you see yourself : my code

Upvotes: 0

Views: 94

Answers (3)

Dennis
Dennis

Reputation: 32608

This is probably what you want. It grabs a column, duplicates it, sets the input to "" and inserts it before the "add" button

http://jsfiddle.net/n4YFK/1/

Upvotes: 1

ShankarSangoli
ShankarSangoli

Reputation: 69915

Try this js fiddle I think I have done wat you wanted.

http://jsfiddle.net/539LR/6/

Here is the js code

$('a.add_input').live('click', function (e) {
    e.preventDefault();
    var $column = $(this).closest("div.column");
    var input = $column.prev("div.column").clone().wrap("<div />").parent().html();
    $column.before($(input));

});

Upvotes: 1

Semyazas
Semyazas

Reputation: 2101

Use var input = $(".ai_service").find(":eq(0)").html(); instead. See http://jsfiddle.net/539LR/4/ for reference

Upvotes: 0

Related Questions