When my window loads, I want the cursor in this input to be blinking and ready for typing. I have tried using jQuery to make this happen, but for some reason I can't get the .focus() function to work properly.
This is the jQuery snippet I'm using:
$(function() {
var cursor;
$('#cmd').click(function() {
$('input').focus();
cursor = window.setInterval(function() {
if ($('#cursor').css('visibility') === 'visible') {
$('#cursor').css({ visibility: 'hidden' });
} else {
$('#cursor').css({ visibility: 'visible' });
}
}, 500);
});
$('input').keyup(function() {
$('#cmd span').text($(this).val());
});
$('input').blur(function() {
clearInterval(cursor);
$('#cursor').css({ visibility: 'visible' });
});
});
$('#text').focus();