JSFiddle - React, Tailwind, and code Playground

by Twisty

HTML

<div data-role="page">
    <div data-role="header" data-theme="b">
         <h1>Test Focus onLoad</h1>

    </div>
    <div data-role="content">
        <button id="startBtn">Start</button>
        <form>
            <label for="text1">Name (Gets Focus and Prompt)</label>
            <input type="text" name="name" id="text1" />
            <label for="text2">User (No Focus or Prompt)</label>
            <input type="text" name="user" id="text2" />
        </form>
    </div>
</div>

JavaScript

$(function () {
    $("#startBtn").click(function (e) {
        $("#text1").focus();
    });
});