Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to show the default text on a form textboxes using jquery

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 405
    Comment on it

    Here, in this article when i click on one textbox the corresponding text in this textbox hides, and as soon as i click on another textbox the first textbox text appears.

    The following steps are required to make the above task possible

    Step1: Download the jquery file from http://code.jquery.com/jquery-1.6.3.min.js

    Step 2: Add the following script under the head section

    script type="text/javascript">

    $(document).ready(function () {

    $('.tab').focus(function () { $(this).css('background', ''); }); $('.tab').blur(function () { $(this).css('background', 'White'); }); $('.tab').focus(function (e) { if ($(this).val() == $(this)[0].title) { $(this).removeClass("defaulttext"); $(this).val(""); } }); $('.tab').blur(function (e) { if ($(this).val() == "") { $(this).addClass("defaulttext"); $(this).val($(this)[0].title); } }); $('.tab').blur(); });

    Step3: Create a form to check the script is working or not.

        3.1: Create two textboxes and write default text under title tag 
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: