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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:29:51+00:00 2026-05-26T14:29:51+00:00

I am trying to fix this piece of code which on Click, removed the

  • 0

I am trying to fix this piece of code which on Click, removed the input’s value, and on Blur returns the value back into the input. You can see my jsFiddle here to see what I mean:

JSfiddle

The problem

It seems to work for the first two inputs, but then the rest don’t seem to do anything. It also appears to not work with the textarea. Strange behavior here but I’m sure a Javascript head can sort this one out.

Thanks alot!

  • 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-05-26T14:29:52+00:00Added an answer on May 26, 2026 at 2:29 pm

    And now it works: 🙂 http://jsfiddle.net/maniator/3Ys7c/3/

    Use the jQuery data() attrbute:

    jQuery(document).ready(function($) {
        $("input, textarea").focus(function() {
            if (!$(this).data('original')) {
                $(this).data('original', $(this).val());
            }
            if ($(this).val() == $(this).data('original')) {
                $(this).val('').css({
                    'color': "#999999",
                    'background-color': '#c6e9ff'
                });
            }
        });
        $("input, textarea").blur(function() {
            if ($(this).val() == "") {
                $(this).val($(this).data('original')).css({
                    'background-color': '#ffffff'
                });
            }
        });
    });
    

    The reason why yours did not work is because you were using this.id which none of them had. If you just use the data attribute of each input, then each input knows what it should and should not be 🙂

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

Sidebar

Related Questions

I've been trying to fix this for two hours straight and I can't figure
I spent about 4 hours yesterday trying to fix this issue in my code.
Just trying to fix this overlapped labeling: My code: values=c(164241,179670) labels=c(Private, Public) colors=c(#cccccc, #aaaaaa)
I have this piece of code on my website which counts the number of
im trying to fix this while loop but keep running into errors. Basically lets
I'm writing a small piece of code which takes input from a user via
I'm trying to run this piece of code inside my onCreate method as an
I'm actually trying to fix this issue where my projects are always out of
So, I have been trying to fix this for about two months. It all
So yeah, like I said, I've spent a few hours trying to fix this

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.