views:

828

answers:

3

I have a simple input field :

<input type="text" id="someid" name="somename" class="someclass">

I'm trying to append some link right after this; so i'll get :

<input type="text" id="someid" name="somename" class="someclass"> - <a href="#">..</a>

i tried :

$("input#someid.someclass").append(' - <a href="#">Are you sure  ?</a>');

Without success, must be stupid but i can't find out what's wrong.

+5  A: 

Use after instead of append

$("input#someid.someclass").after(' - <a href="#">Are you sure  ?</a>');
T B
Right, working perfectly now. Thanks !
Disco
I don't understand how someone else posted the same answer as me later on deserves to be marked as the answer?
T B
+2  A: 

The append method will add the node you give it to the element you call it on.

In your case, you are putting the HTML inside the INPUT element.

You need to use the after method to insert the HTML after your INPUT element.

SLaks
+2  A: 

Try .after() instead:

$("input#someid.someclass").after(' - <a href="#">Are you sure  ?</a>');
Uh Clem