Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8020747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:46:34+00:00 2026-06-04T21:46:34+00:00

I have this following codes that works perfectly on jQuery 1.3.2 : $(#passwordLabel).click(function() {

  • 0

I have this following codes that works perfectly on jQuery 1.3.2 :

        $("#passwordLabel").click(function()
            {
                $(this).hide();
                $("#password").focus();
            }
        );

        $("#confirmpasswordLabel").click(function()
            {
                $(this).hide();
                $("#confirmpassword").focus();
            }
        );

        $("#password").focus(function()
            {
                $("#passwordLabel").hide();
            }
        );

        $("#confirmpassword").focus(function()
            {
                $("#confirmpasswordLabel").hide();
            }
        );

        $("#password").blur(function()
            {
                if($(this).val()=="")
                {
                    $("#passwordLabel").show();
                }
            }
        );

        $("#confirmpassword").blur(function(value)
            {
                if($(this).val()=="")
                {
                    $("#confirmpasswordLabel").show();
                }
            }
        );
    });

but unfortunately, this codes doesn’t work anymore when I change my jQuery Library into version 1.6.4.

is that because jQuery 1.6.4 doesn’t have that syntax anymore?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:46:36+00:00Added an answer on June 4, 2026 at 9:46 pm

    Fine name you have there by the way.

    It looks like your new to JavaScript. Let me give you some pointers. Firstly you should try to reduce the number of times you ask the browser for an element. With jQuery all you have to do is save the selected element to a variable. I personally like to prepend my element variables with $ so I know that there jQuery elements.

    //too many selections
    $('element').foo(); //query 1
    $('element').bar(); //query 2
    $('element').baz(); //query 3
    
    //better
    $element = $('element'); //query 1
    $element.foo();
    $element.bar();
    $element.baz();
    

    The second thing is that you should always keep your { on the same line as the start of your block. In most languages this doesn’t matter and in a lot of cases it will work in JavaScript but because of semicolon insertion its best to keep your { on the same line.

    //one example of why this is bad
    return
    {
        "foo": "bar"
    };
    
    //The above actually becomes
    return;
    {
        "foo": "bar"
    };
    
    //should have actually been
    return {
        "foo": "bar"
    };
    

    The last thing I noticed is that your having javascript focus each input when the corresponding label is clicked. This can actually be done without JavaScript. All you need to do is add the for attribute to your labels. They should be set to the id of there corresponding input.

    <!-- from this -->
    <label id="passwordLabel">Password</label>
    <input id="password" type="password">
    
    <!-- to this -->
    <label id="passwordLabel" for="password">Password</label>
    <input id="password" type="password">
    

    Anyway provided you fixed your html the following should do the trick.

    //Wait for the page to load
    $(function() {
        var $passwordLabel, $confirmpasswordLabel, $password, $confirmpassword;
    
        //Pre select the form elements
        $passwordLabel = $("#passwordLabel");
        $password = $("#password");
        $confirmpasswordLabel = $("#confirmpasswordLabel");
        $confirmpassword = $("#confirmpassword");
    
        //bind events for the password input
        $password.focus(function() {
            //on focus hide the label
            $passwordLabel.hide();
        });
        $password.blur(function() {
            if(!$password.val()) {
                //if the input is empty then restore the label on blur
                $passwordLabel.show();
            }
        });
    
        //bind events for the confirm password input
        $confirmpassword.focus(function() {
            //on focus hide the label
            $confirmpasswordLabel.hide();
        });
        $confirmpassword.blur(function() {
            if(!$confirmpassword.val()) {
                //if the input is empty then restore the label on blur
                $confirmpasswordLabel.show();
            }
        });
    });​
    

    If you want to see some working code I made you a jsFiddle with the example above and some sample inputs: http://jsfiddle.net/wef85/8/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: Bear in mind that while this code works on
I have the following Javascript/jQuery function: function addEventHandler(){ $(div).mouseenter(function() { $(this).html(Over); }).mouseleave(function() { $(this).html(Out);
I have a form that works perfectly. Now, when i add the following code,
I have a simple script in jQuery that works perfectly with jQuery 1.5.2 as
I have the following jQuery script... $(function() { $('.eventWrapper').bind('click', function(event) { var srvName =
I have the following code that works perfectly. It allows the user to 'like'
I have the following HTML/JS/jQuery Code. This code represents a login form that is
I have the following code block that fails: this.redisClient.hmset('user:' + userObj.getUserId(), { 'userId' :
I have the following code in this jsFiddle. The problem I'm having is that
I have a Nancy JSON REST service that uses the following serialisation code... FormatterExtensions.AsJson(this.Response,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.