开发者

Add new field to paragraph when link is clicked?

开发者 https://www.devze.com 2023-03-05 22:36 出处:网络
I have a form where I would like to add new fields for file uploading when the user clicks a link. So I have made a pa开发者_Python百科ragraph with id:

I have a form where I would like to add new fields for file uploading when the user clicks a link.

So I have made a pa开发者_Python百科ragraph with id:

<p id="proof">default field is here and want more</p>

Then on my jQuery I have:

$('#newField').click(
    function(){
        $('#proof').append('<label for="file">Arquivo:</label><input type="file" name="arquivo[]" id="file" /><br />\n<label>Descrição:</label><input type="text" name="descricao[]" class="text small" /><br />');
        return false;
    }
);

And here I have the link that should be clicked to add new fields:

<a href="#" id="#newField">Mais provas</a>

I am quite new to jQuery and not sure if I could add it to a paragraph or if I am tied to a div and if it should work for a paragraph what have I done wrong here ?

It is not adding new fields as I was hoping it would, in fact it doesnt add nothing when u click the link.


use

<a href="#" id="newField">Mais provas</a>

instead of

<a href="#" id="#newField">Mais provas</a>

You have added an extra # in id of link.

0

精彩评论

暂无评论...
验证码 换一张
取 消