Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

JavaScript Change focus to password field login page being reset

This sounds like a timing issue, there is probably already some JS running after your script is ran.

Try wrapping your JS in $(window).load(), this will run the function after other page assets have loaded and should fix the timing issue.

For example…

$(window).load(function() {
    document.getElementById('user_pass').focus();
});

Here is some info about the difference between $(document).ready() vs $(window).load().

Related Posts:

  1. What is the preferred way to add custom javascript files to the site?
  2. Does the functions.php file ever get called during an AJAX call? Debug AJAX
  3. theme path in javascript file
  4. pass object/JSON to wp_localize_script
  5. Solutions for generating dynamic javascript / CSS
  6. Proper, exhaustive documentation for wp.editor etc
  7. Any alternate TinyMCE4 themes / subthemes?
  8. Is there a way to set the order of wp_footer hooked functions?
  9. Google Maps not displaying in wordpress using Google Maps Javascript API
  10. Trigger Customizer saving process with Javascript only
  11. What is the best practice for customizing a plugin’s JavaScript/jQuery?
  12. Changing the entire control choices using wp.customize with JavaScript
  13. How to Change CSS Variable value in Theme Customizer Live Preview
  14. Modifying JS files in Child-theme
  15. Whats the safest way to output custom JavaScript and Css code entered by the admin in the Theme Settings?
  16. WordPress Customizer Control with React
  17. How to configure wordpress to work with Vuejs with SSR and without hashbang
  18. How to hook CSS file according to theme selection in the customizer section
  19. How to correctly add JQuery in a WP theme?
  20. using wordpress without javascript
  21. Including Javascript options
  22. jQuery not available to other scripts
  23. How to make Isotope and WordPress work together?
  24. Single page site with history.js
  25. How to add material design css in wordpress and woocommerce
  26. Use second time navigation.js in underscores [closed]
  27. Theme Javascript.php Overwritten Nightly [closed]
  28. How to: JQuery multiple wordpress media uploader buttons in the same options page?
  29. How to get javascript slider to work! [closed]
  30. Theme Customizer not loading JS for live preview
  31. My jQuery is enqueued properly. So why isn’t it working?
  32. Enqueued JavaScript is not working
  33. How to register and enqueue JavaScript files without breaking plugin dependencies?
  34. wp_enqueue_script not working?
  35. How can I wrap all blog posts image with
  36. White screen when attaching css to function.php
  37. WordPress theme resource won’t load over VPN
  38. pass wordpress template directory into ajax url call
  39. theme-independent CSS/JS files
  40. Javascript development in Custom Themes
  41. add jquery file if a certain page is included
  42. enqueuing external and internal js and css in wordpress did not work with owl.js animate.css
  43. getBoundingClientRect() showing different values on load vs scroll
  44. wordpress script_loader_tag in function.php
  45. How to diagnose wp-env environment problem
  46. How to enqueue scripts properly with ES6 webpack?
  47. Ajax Comment Upvotes – Votes don’t always register
  48. change background image on scroll
  49. Customizer Image-Picker Preview Not Working
  50. Does any JavaScript file load automatically for index.php file?
  51. How would I get this to work – send to post from thick box
  52. Theme Development for a Newbie
  53. Flexslider not working for my custom theme WordPress
  54. Theme customizer live preview JS- Trying to bind to an html image url without luck
  55. Can’t attach Javascript to theme
  56. Set start page depending on screen width [closed]
  57. wp_deregister_script was called incorrectly
  58. Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
  59. Using wp_enqueue_script with social media buttons?
  60. How to convert that page to a wordpress template? [closed]
  61. wp_enqueue_script causes page to vanish
  62. How to reuse parts of WordPress site e.g. header, footer, part of header for multiple WordPress sites?
  63. Theme now uses require.js and enqueue script no longer works
  64. can’t add EVENT LISTENER to a element
  65. What is The Best Way to Make Parallax header effect for wordpress theme ?? pure CSS or using JavaScript? [closed]
  66. WP site makes mobile browser crash for high memory usage
  67. How can i move my product name & price from below thumbnail to be the rollover content in Avada & Woocommerce?
  68. jQuery Snippet Not Working on WordPress Site [closed]
  69. WP Customizer get control value on change
  70. Execute javscript when theme customizer loads (autosave issue)
  71. When trying to run build script with gutenberg (with SVG import) – Error: Plugin name should be specified
  72. Is there any halfway decent documentation on the wp.media JS class?
  73. Smooth Scrolling Animation of Image Between Two Containers (Elementor) Using JavaScript and GSAP
  74. How to add group-row to InnerBlock template?
  75. Javascript localization doesn’t load. How to Internationalize javascript without plugin?
  76. How to Use Webpack with WordPress Script Modules and Enqueue a Custom Class
  77. Menu items description? Custom Walker for wp_nav_menu()
  78. How to define and link full path to css located at a random folder on header.php
  79. Sizing screenshot.png without losing aspect ratio
  80. Software for WordPress Theme and Plugin Development? [closed]
  81. When to use is_home() vs is_front_page()?
  82. Get the blog page URL set in Options
  83. How to create .pot files with POedit?
  84. How do I get the theme URL in PHP?
  85. Why when I submit a form in wordpress it loads a 404 page though URL is correct
  86. What is the constant WP_USE_THEMES for?
  87. Worthwhile to restrict direct access of theme files?
  88. How Do I Protect My Premium WordPress App Theme from Copying?
  89. How to detect mobile devices and present them a specific theme?
  90. Using wp_add_inline_style without a stylesheet
  91. How to add posts to custom menus?
  92. WordPress Theme Preview Image
  93. How To extend WP_Customize_Control
  94. What is the difference between front-page.php and home.php? [duplicate]
  95. How can I get page slug
  96. When to use _e and __ for the translation?
  97. What is a Theme textdomain?
  98. How to show a custom meta box on the “Quick Edit” screen?
  99. How to add CSS class to custom logo?
  100. How to add custom css file in theme?
Categories theme-development Tags javascript, theme-development, wp-login-form
How do you modify the WordPress directory structure?
Trouble creating conditional PHP for nav menu items with children for custom Walker

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress