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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:31:42+00:00 2026-05-12T09:31:42+00:00

I have a problem with this jQuery code: $(document).ready( function(){ alert($(‘#search’).val()); var dummyInput =

  • 0

I have a problem with this jQuery code:

$(document).ready( 
  function(){  
    alert($('#search').val());  

    var dummyInput = $('#search').clone()
    .attr('id', 'search_watermark')
    .val('Search query')

    $('#search').before(dummyInput);
  }
);

$(window).unload(function(){
  $('#search_watermark').remove();
});

and the HTML:

<form id='test_form' action='/test.php' method='post'>
  <label>Create New Team</label><br/>
  <input type='text' id='search' />
</form>

The problem is:

We are assigning a value only to the clone of the input field, not the actual input field. But you will find that in Firefox, when you refresh the page, the value of the actual input field has changed. This behaviour is unexpected.

All other browsers (except FF) behaving as expected. I am using FF 3.5 on XP.

  • 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-12T09:31:42+00:00Added an answer on May 12, 2026 at 9:31 am

    I had to wrap my brain around the question because the alert kind of put me off. Assign some names to your input fields and when you do the clone, give it a different name, ie.+

    var dummyInput = $('#search').clone()
    .attr('id', 'search_watermark')
    .val('Search query').attr( 'name', 'foo' );
    

    Firefox will remember the input, it has nothing to do with JS. If you do a full refresh (+Shift) it should clear out the input from the example you posted as well.

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

Sidebar

Ask A Question

Stats

  • Questions 169k
  • Answers 169k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In order to query information about processes that you don't… May 12, 2026 at 1:59 pm
  • Editorial Team
    Editorial Team added an answer AMD is switching to OpenCL based API soon. May be… May 12, 2026 at 1:59 pm
  • Editorial Team
    Editorial Team added an answer Unless someone pipes up with a mono way to do… May 12, 2026 at 1:59 pm

Related Questions

I have a problem with this jQuery code: $(document).ready( function(){ alert($('#search').val()); var dummyInput =
I have an issue with this jquery code below. Please give me advice or
I have a problem with the jquery-ui dialog box . The problem is that
I have a little problem with some jquery and http://www.mikage.to/jquery/jquery_history_noc.html The function works great,
I have a form which has a input textbox and submit button. On submission

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.