Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set focus when there are many textbox using jquery?

Tags:

jquery

I want to set focus to the textbox when i click the text box. I tried the below code but am not getting as expected .

$('#txtDate').focus();

Thanks in advance.

like image 980
Sujeeth Avatar asked Aug 26 '13 05:08

Sujeeth


2 Answers

This will work

$('input').click(function() {
  $(this).focus();
})
like image 169
Anil kumar Avatar answered Sep 24 '22 16:09

Anil kumar


Demo

Use Document.ready Try this..

 $(function(){
    $("#txtDate").focus();
  });
like image 29
Prabhakaran Parthipan Avatar answered Sep 24 '22 16:09

Prabhakaran Parthipan