Well I have made some changes to the test.html to achieve the desired results :
<html> <head> <title></title> <script src="http://code.jquery.com/jquery-latest.pack.js" type="text/javascript" language="javascript" charset="utf-8"></script> <script type="text/javascript" language="javascript" charset="utf-8"> // <![CDATA[ $(document).ready(function() { $('#another').click(function() { var id = "word" + $('input').length $('input:last').after('<label for="' + id + '"></label><input type="text" name="' + id + '" id="' + id + '" value="" size="50" />'); return false; }); }); // ]]> </script> </head> <body> <label for="word">Texto:</label> <input type="text" name="word" id="word" value="" size="50" /> <a href="" id="another">Adicionar criterio</a> </body> </html> This will achieve what you want. Thanks & Regards, Dhruva Sagar. Joan Crawford<http://www.brainyquote.com/quotes/authors/j/joan_crawford.html> - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend." On Tue, Nov 3, 2009 at 9:08 AM, ReynierPM <rper...@uci.cu> wrote: > Dhruva Sagar wrote: > >> Where have you added the $('#another').click() ? >> Is it even in $(document).ready() or not ? Are you sure that the click >> handler is even being called ? >> >> I have created a test.html and tested what you want, it works perfectly >> for >> me. >> >> <html> >> <head> >> <title></title> >> <script src="http://code.jquery.com/jquery-latest.pack.js" >> type="text/javascript" language="javascript" charset="utf-8"></script> >> <script type="text/javascript" language="javascript" charset="utf-8"> >> // <![CDATA[ >> $(document).ready(function() { >> $('#another').click(function() { >> $('#word').after('<label for="word2"></label><input >> type="text" name="word2" id="word2" value="" size="50" />'); >> }); >> }); >> // ]]> >> </script> >> </head> >> <body> >> <label for="word">Texto:</label> >> <input type="text" name="word" id="word" value="" size="50" /> >> <a href="#" id="another">Adicionar criterio</a> >> </body> >> </html> >> >> Thanks & Regards, >> Dhruva Sagar. >> >> > Ohh I see my mistake now I forget to write this code inside $().ready() for > that it wont work. Now I have a second question: how I can generate > dinamically the number for element input id? I mean every time I click the > link the id will be incremented in one so will be: word1, word2, wordn > Thanks > -- > Saludos > ReynierPM >