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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:04:30+00:00 2026-05-30T00:04:30+00:00

I am trying to get a input and textarea label hide/show function to work,

  • 0

I am trying to get a input and textarea label hide/show function to work, but my Jquery skills are not good enough..:/

You probably seen this a thousand times, and I have read page up and down about it, but still I havent been able to figure it out.

The first part of the code works fine, it changes the text to a lighter color when the element gets focus, and disappears when you start to type. It is probably not very well written, but it is to the best of my abilitys right now.

$("input, #email_text").focusin(function(){

$("label.input", this).css("color", "#f3f3f3");

});

$("input, #email_text").keypress(function(){

$("label.input", this).fadeOut("normal");

});

Here I want the script to do the following: If the element loose focus, I want the labeltext to fade back in, exept if the user have written something in the field. I probably have the if/else statement screwed up, and I have not yet got a grip on the .val function.

$("input, #email_text").focusout(function() {

if($("#email_text").val() !="") {

$("label.input", this).fadeIn("normal").css("color", "#f3f3f3");

}} else { 

("label.input", this).hide();

});

Can anyone give me a hand with this? I`m kind of giving up on this, and should probably have started with something more basic.

Thanks in advance!

Regards,

Vegar Vallestad

Edit:

The html looks like this:

<div id="email_text">
<label class="input">Please leave a message..</label>
<textarea name="message" id="email_text"><?php echo "</tex" . "tarea>"; ?>
</div>
  • 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-30T00:04:31+00:00Added an answer on May 30, 2026 at 12:04 am
    $("input, #email_text").on({
        focus: function() {
            $("label.input", this).css("color", "#f3f3f3");
        },
        keyup: function() {
            $("label.input", this).fadeOut();
        },
        blur: function() {
            if($("#email_text").val() !="") {
                $("label.input", this).css("color", "#f3f3f3").fadeIn();
            } else { 
                $("label.input", this).hide();
            }
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get console input in my Clojure program, but when it gives
I'm trying to get all the input elements from a certain form from jQuery
I'm trying to get my name and trip input fields to line, but they're
I'm trying all day and can't get this to work. I have four input
I'm trying to get the value of an input (text/textarea) and document.getElementById('rtext').value returns nothing.
I'm trying to get the following jquery toggle to work on IE, FF, and
I've been trying to get input with IUP to make a small pong game.
i am currently trying to get Input Mode Editor (IME) support working with a
I am trying to get text input from the keyboard in Java 6. I
I am having a terrible time trying to get an input box like 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.