jQuery Floating Label – Move Placeholder to Top on Typing

Here is a jQuery Floating Label plugin that smoothly float the placeholder text over the input. This lightweight jQuery plugin get the text from label and insert it as placeholder into an input. Then move this text to top of input on typing.

Plugin Overview

Plugin: Floating Label
Author: Charles Hudson
Licence: MIT Licence
Published: May 11, 2019
Repository: Fork on GitHub
Dependencies: jQuery 1.3.1 or Latest version,
File Type: zip archive (HTML, CSS & JavaScript )
Package Size: 3.17 KB

How to Make jQuery Floating Label

1. Create input filed with label whose placeholder text you want to float.
Note: No need for creating placeholder text, it will automatically inserted from label text.

<label for="name">Name</label>
<input id="name" type="text" />

2. After that, load the jQuery JavaScript library and Floating Label‘s Js file into HTML document.

<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

<!-- Floating Label Js -->
<script src="js/floating-label.jquery.js" type="text/javascript"></script>

3. Finally, call the plugin with label selector in jQuery document ready function.




Be the first to comment

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.