javascript - Focus the first input on load only if no input is focused -


i'm trying set default focus pages of site without changing focus on page reload.

i mean:

  • user opens page.
  • focus automatically set on 1st input.
  • user changes focus 3rd input.
  • user refreshes page.
  • focus must not change 1st input again. (this requirement fail accomplish).

my current code follows:

$(document).ready(function() {      if($(':focus').length === 0) {         $(':input:not([type="hidden"]):first').focus();     }  }); 

the condition true every time!

$(document).ready({  window.onload=function(){ if(session.storage.getitem("text3")){//if key= text3 set,then change focus 3rd text box. $('#your3rdtextid').focus(); }   $('#your3rdtextid').focus(function(){     session.storaage.setitem("text3","selected")//here set key text3 , value selected later use. });   }); 

you can provide own custom conditions.this small example.hope helped you.good luck project.

link-->html5 local storage vs. session storage

link-->http://www.w3schools.com/html/html5_webstorage.asp


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -