Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery : Append text after an input field

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.

like image 233
Disco Avatar asked Sep 29 '09 15:09

Disco


People also ask

How do you add to the input field?

To append an element with a text message when the input field is changed, change() and appendTo() methods are used. The change() method is used to detect the change in the value of input fields.

What is insertAfter in jQuery?

The insertAfter() is an inbuilt method in jQuery which is used to insert some HTML content after a specified element. The HTML content will be inserted after each occurrence of the specified element. Syntax: $(content).insertAfter(target)

Which jQuery function adds HTML content outside a selection?

prepend() - insert content at the start of selected element (inside its HTML tags) . after() - insert content after the selected element (outside its HTML tags) .


1 Answers

Use after instead of append

$("input#someid.someclass").after(' - <a href="#">Are you sure  ?</a>');
like image 148
Tim Banks Avatar answered Oct 04 '22 20:10

Tim Banks