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

  • Home
  • SEARCH
  • 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 7780441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:53:55+00:00 2026-06-01T18:53:55+00:00

http://jsfiddle.net/nFFuD/ I’m trying to animate the search field in this example using jquery, making

  • 0

http://jsfiddle.net/nFFuD/

I’m trying to animate the search field in this example using jquery, making it move to the top of it’s containing div oninput. I was originally using scriptaculous effect.move to do this, but I couldn’t make the event only fire once, so if someone kept typing after the first keystroke, the effect would stop and start again from it’s current position in the animation for each additional keystroke, which is stupid. I’m new to new to using jquery so please, take it easy if I’m not making very much sense.

EDIT: The example that ocanal posted definitely works, but for some reason it’s not working for me when I apply it – here’s what I currently have so far – also trying to fade a div on the same event

<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>Untitled</title>
<head>
<meta charset="utf-8">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">

$('#search').keypress(function() {

    $(this).animate({
    top: '0',
  });

    $('#icon).fadeOut('slow', function() {

    }); 

});​

</script>
<style type="text/css" media="screen">

body {
    margin: 0px;
    padding: 0px;
}

#container {
    position: relative;
    border: #000 1px solid;
    margin: 0px auto;
    width: 960px;
    height: 800px;
}

input {
    outline: none;
}

#icon {
    position: absolute;
    top: 80px;
    left: 370px;
    width: 200px;
}

#search {
    position: absolute;
    top: 300px;
    left: 230px;
            width: 500px;           
}

</style>
</head>
<body>  
<div id="container">
    <img id="icon" src="icon.png" alt="icon">           
    <input id="search" type="text" autofocus="autofocus">
</div>
</body>
</html>
  • 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-01T18:53:58+00:00Added an answer on June 1, 2026 at 6:53 pm

    change works like blur, so you should do that with keypress event I think,

    $('#search').keypress(function() {
    
        $(this).animate({
        top: '0',
      });
    });​
    

    http://jsfiddle.net/ocanal/nFFuD/7/


    EDIT:

    the code you shared is not working, because you should initialize event functions when dom is ready, you don’t need to use it in jsFiddle, because you can select the time when script will work.

    $(document).ready(function() {
    //your functions.
    });
    

    than it will work.

    $(document).ready(function() {
      $('#search').keypress(function() {
    
          $(this).animate({
          top: '0',
        });
    
          $('#icon').fadeOut('slow', function() {
    
          }); 
    
      });
    });
    

    and here is your working code

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

Sidebar

Related Questions

http://jsfiddle.net/zTTxu/ How can I animate once when page1 load example: animate 'a' to 'b'
http://jsfiddle.net/9BCrs/5/ I have this set up to load a file into a DIV using
http://jsfiddle.net/AYPze/9/ In this example I have two similar divs with the same goal. Bind
http://jsfiddle.net/B2rdD/3/ I've Created 25 buttons using HTML and I have written jquery code such
http://jsfiddle.net/JamesKyle/y7hBQ/ I'm making a simple jquery counting function that adds the following classes: First
http://jsfiddle.net/nf8NM/3/ This is my first foray into Backbone and I am simply trying to
http://jsfiddle.net/ksHuz/ I'm trying to use a background-image with the <a> element in this fiddle,
http://jsfiddle.net/fSrBv/ I'm having an issue here where in my From field I'm able to
http://jsfiddle.net/nUcXQ/ How to get dynamic height on the main (black background) I'm using image
http://jsfiddle.net/rFEER/ <select id=users> <option value=1>jack</option> <option value=2>brill</option> <option value=3>antony</option> </select>​ js: $(#users).change(function(){ alert($(this).val()); })​

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.