Alright i have a asp.net textbox and i want to set cursor inside textbox after page loaded like when you open google.
I only need set cursor inside textbox code.
I tried this but not working
$('txtSendTo').focus();
This can be done by using the focus() method and click() method. We will create a web page with a textbox and a button. We will add the functionality using jQuery such that on clicking the button, the cursor is set to the textbox.
If txtSendTo
is an id
, you need a #
$('#txtSendTo').focus();
If txtSendTo
is a class
, you need a .
$('.txtSendTo').focus();
Or, if there is only one textbox
on the page
$('textbox').focus();
Also make sure the page is fully loaded before you try to search the dom:
$(document).ready(function () {
`$('textbox').focus();`
});
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