Jquery watermark text of textbox example

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


Popular posts from this blog

difference between structure and union in C Language

Difference between Linear search and Binary Search in c language

Difference between static and dynamic websites