Can you please tell me how to get the click event of an input text field in jQuery? I have one input text field I need click event of that showing alert.
<div data-role="fieldcontain">
<label for="text-12" class="name_label_field">Name<span class="custom-label">*</span> :</label><span class="mandatory_label fright custom-label">*<span class="test_1">Maximum Limit 260</span></span>
<input name="text-12" id="text-12" value="" type="text" class="documentName_h name_input_box" autocorrect="off" maxlength="240" onkeypress="validateNote(event)">
</div>
Can you please tell me how to get the click event of an input text field in jQuery? I have one input text field I need click event of that showing alert.
<div data-role="fieldcontain">
<label for="text-12" class="name_label_field">Name<span class="custom-label">*</span> :</label><span class="mandatory_label fright custom-label">*<span class="test_1">Maximum Limit 260</span></span>
<input name="text-12" id="text-12" value="" type="text" class="documentName_h name_input_box" autocorrect="off" maxlength="240" onkeypress="validateNote(event)">
</div>
Share
Improve this question
edited Apr 13, 2014 at 17:31
Jason Aller
3,65228 gold badges41 silver badges39 bronze badges
asked Apr 13, 2014 at 10:02
user2484319user2484319
1
- jsfiddle/p9TC4 – caramba Commented Apr 13, 2014 at 10:04
3 Answers
Reset to default 2 $('#text-12').click(function(e) {
alert('clicked');
});
in general, for all text inputs, use input[type="text"]
instead of #text-12
selector.
Another solution:
$('#text-12').on('click',function(){alert("alert-title")});
You can use the code below
$('#text-12').click(function(){ alert("hello")});