How to add label before textbox
Hi - First time poster here. I've never used jquery or much javascript at all. I have to add a label above 2 text boxes - I've tried various ways of using append and prepend and nothing works. This is the code I have:
- <form class= "login-form">
- <div class="form-group">
- <input class="form-control" placeholder="Username"></input>
- </div>
- <div class="form-group">
- <input class="form-control" placeholder="Password"></input>
- </div>
- ...
- </form>
- inside I want:
- <div class="form-group">
- <label class='login-label'>Username</label>
- <input id="login" class="form-control"></input>
- </div>
- <div class="form-group">
- <label class='password-label'>Password</label>
- <input id="password" class="form-control"></input>
- </div>
I was trying something like this (for login):
- $(document).ready( function() {
- $( "#login" ).prepend( "<label class='login-label'>Username</label>" );
- });
Nothing displays in UI but this displays when I inspect in dev tools:
- <input id="login"name="login" placeholder="Username" class="form-control" >
- <label class="login-label">Username</label>
- </input
Your help is appreciated - thanks!