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.
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.
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)
prepend() - insert content at the start of selected element (inside its HTML tags) . after() - insert content after the selected element (outside its HTML tags) .
Use after instead of append
$("input#someid.someclass").after(' - <a href="#">Are you sure ?</a>');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With