WackGet
WackGet

Reputation: 2916

Removing focus from an input element so the page can be scrolled using the arrow keys?

I have a page with a few text box inputs. By default, the first text box has focus (the cursor waits inside the text box for the user to start typing) as soon as the page loads.

Although convenient, this means the up/down arrow keys cannot be used to scroll the page.

I tried:

  // When DOWN key is pressed...
  $("body").focus(); // or...
  $("body").first().focus(); // or...
  $("a:visible").first().focus();

But it doesn't work. I still have to click outside of the input box in order to start using up/down arrows to scroll again.

Upvotes: 0

Views: 2889

Answers (1)

Edwin Alex
Edwin Alex

Reputation: 5108

Use this, it will solve your problem.

$(function(){
    $("input").blur();
}

Upvotes: 2

Related Questions