devwiki:html

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
devwiki:html [2021/08/28 07:37] – [css file not loading] yingdevwiki:html [2021/12/20 07:19] – [html select dropdown and remove focus] ying
Line 192: Line 192:
   }   }
 } }
 +</code>
 +
 +===== html select dropdown and remove focus =====
 +  * problem: when select dropdown, the select focus still stuck on the dropdown list, (when you press arrow key)
 +  * solution: to remove focus after choose, add onchange event and remove its focus <code javascript>
 +const choice_input = document.querySelector(".my_choice")
 +choice_input.onchange = function(event){
 +choice_input.blur() // remove focus from this input
 +}
 +// also if you have onload function, you can add this to onload to reset last choice when refresh browser
 +const tmp_choice_input= document.querySelector(".my_choice")
 +tmp_choice_input.selectedIndex = "0";
 </code> </code>
  • devwiki/html.txt
  • Last modified: 2023/02/07 18:21
  • by ying