Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert text into the input/textarea using Jquery

<div class="ctrlHolder">
<label for="" id="name.label">Name</label>
<input name="name" id="name" type="text" class="textInput small" />
<p class="formHint">The name of the item you are submitting</p>
</div>

How can I insert predefined text into a input element. I'd like this function to active when the user doubleclicks the label element.

$('#name.label').dblclick(function(){
    $('#name').val('some text');
});
like image 943
Ambo100 Avatar asked Sep 15 '25 05:09

Ambo100


1 Answers

here check this fiddle

you can use .text("yourPreDefinedText") to replace the text of an element

like image 98
Rafay Avatar answered Sep 16 '25 17:09

Rafay