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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:57:06+00:00 2026-05-24T22:57:06+00:00

I have an input with an X (clear) button to clear the value. I

  • 0

I have an input with an X (clear) button to clear the value. I want that button to fadein if there is a value in the input.

Here is a fiddle of what I have: http://jsfiddle.net/3m25K/

<input class="inputfield">
$('input.inputfield').wrap('<span class="deleteicon" />').after($('<span/>').click(function() {

    $('.inputfield').val('').focus();
}));
input{
    font-size:22px;}
span.deleteicon {
    position: relative;
}
span.deleteicon span {
    position: absolute;
    display: block;
    top: -5px;
    right: 7px;
    width: 24px;
    height: 24px;
    background:black;
    cursor: pointer;
}
  • 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-24T22:57:06+00:00Added an answer on May 24, 2026 at 10:57 pm

    You could just add a keyup handler and check the if the <input>‘s value has transitioned from none to some or some to none and then apply a fadeIn or fadeOut to the button. Something like this:

    $('.inputfield').keyup(function() {
        var $span = $('.deleteicon span');
        if(this.value.length > 0 && !$span.is(':visible'))
            $span.stop().fadeIn();
        else if(this.value.length == 0)
            $span.stop().fadeOut();
    });
    

    Live version: http://jsfiddle.net/ambiguous/MDnac/3/

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

Sidebar

Related Questions

I have a clear button that I want to tie into some php coding.
I have an input file that I want to sort based on timestamp which
We have some input data that sometimes appears with &nbsp characters on the end.
I have this input text: <html><head><meta http-equiv=content-type content=text/html; charset=utf-8></head><body><table cellspacing=0 cellpadding=0 border=0 align=center width=603>
I've got a script that disables a button input control, empties a table body
I have a form with two input fields and a tag cloud. I want
I have the following bit of jQuery for adding a clear button to the
I have a MySQL query that fetches a numeric value VARCHAR (20) from a
I have an file upload box and a clear button on my page. When
I have this div that when the mouse enters it, I want it to

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.