Adding/Hiding Labels

<div data-role="fieldcontain" class="ui-hide-label">   <label for="username">Username:</label>   <input type="text" name="username" id="username"     value="" placeholder="Username"/> </div>

Labels are required on form inputs in jQuery Mobile. This allows the library to format the form elements appropriately for mobile devices. Therefore, you need to add a label and use the for attribute to link it to the form input. The good news is that jQuery mobile provides a class that you can easily hide the label with.

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.