Reputation: 1189
<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');
});
Upvotes: 4
Views: 37812
Reputation: 31043
here check this fiddle
you can use .text("yourPreDefinedText") to replace the text of an element
Upvotes: 7
Reputation: 8657
$('#name.label') will cause jQuery to look for an element with id "name" and class "label". I believe the code above should work if you rename the label's id to something like "name-label".
Upvotes: 1