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 8354421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:32:36+00:00 2026-06-09T09:32:36+00:00

I have input in HTML-page: <input id=Name name=Name tabindex=0 type=text value=Name: /> I wrote

  • 0

I have input in HTML-page:

<input id="Name" name="Name" tabindex="0" type="text" value="Name:" />

I wrote javascript with jQuery to bind handlers for events “onfocus” and “onblur”:

<script type="text/javascript">
    var name = $("#Name");
    name.focus(function () {if ($(this).val() == "Name:") $(this).val('');});
    name.blur(function () {if ($(this).val() == "") $(this).val("Name:");});
</script>

So, when user chooses input, it’s value should become empty. If user doesn’t enter text in input and change focus, input’s value returns to ‘Name:’.

It works fine in Firefox, Internet Explorer and Opera, but it doesn’t work in Google Chrome. Furthemore, there is error in chrome debugger: “Uncaught TypeError: Object [object Object] has no method ‘focus'”.

How can I bind handlers with jQuery in Google Chrome?
Thanks!

  • 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-09T09:32:38+00:00Added an answer on June 9, 2026 at 9:32 am

    Somehow Chrome doesn’t like your variable to be named “name” in this case. The following works

    <script type="text/javascript"> 
        var name2 = $("#Name"); 
        name2.focus(function () {if ($(this).val() == "Name:") $(this).val('');}); 
        name2.blur(function () {if ($(this).val() == "") $(this).val("Name:");}); 
    </script> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have 5 inputs ( type=text ) on html page /edit_person.php : <input id=name
I have an input on an HTML page where a person will type something
I have the following HTML on my web page: <input id=htmlEdit type=checkbox/> Once the
I have a form with different html input fields... 1) <input type=text> 2) <textarea></textarea>
I have a button in my abc.html page <input type=button onclick=javafun();> on the click
I have to do an HTML page with 2 text boxes, one for name
I have a JS script that appends to the HTML page the pairs: input
I have a page with File html input field and a Submit button as
I have an html page with JavaScript code for setting the phone number format
I have a simple javascript question in the HTML page. In my case, the

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.