Jquery watermark text of textbox example

October 10, 2015 0 Comments

In this article i will show you, water text of textBox using JQuery. i will give you an example of it. When first time browser load, all textbox generate a function, which are contains title of the textbox. Also add a class with all textboxes. Lets see the example of JQuery Watermark text:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">



    <script src="Scripts/jquery-1.10.2.js"></script>
        $(document).ready(function () {
            $('input[type="text"]').each(function () {

                this.value = $(this).attr('title');

                $(this).focus(function () {

                    if (this.value == $(this).attr('title')) {

                        this.value = '';

                $(this).blur(function () {
                    if (this.value == '') {
                        this.value = $(this).attr('title');




    UserName: <input type="text" value="" name="username" title="Enter UserName"/>

Code Generate the following output:

Jquery watermark text of textbox example

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google