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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:17:11+00:00 2026-05-21T22:17:11+00:00

I have an auto-complete text field for cities. For example cities are suggested in

  • 0

I have an auto-complete text field for cities. For example cities are suggested in a dropdown list while you type. Upon selecting a city I use hide() to hide the text field and append the selected city name to a #city div, replacing the text field.

I also have an edit button that makes the text field reappear. So when I click edit it should clear the previous appended city name and replace it with the new one I select.

It’s sort of like this. But I completely remove the text field http://www.emposha.com/demo/fcbkcomplete_2/

$('#edit').click(function() {
              $(this).hide(); //hide edit button
              $("#city").append(""); //clear city name
              $("#city_text_field").show(); //show text field         
            });

When selecting a city again I use

$('#city').append('selected city');

this appends the new city by the previous one instead of replacing it. I also tried replaceWith() but nothing happens.

Can anyone please suggest a Jquery function that is suitable for this?

  • 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-21T22:17:12+00:00Added an answer on May 21, 2026 at 10:17 pm

    You could first use

    $("#city").empty();
    

    or directly replace the contents with

    $("#city").html('selected city');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an auto-complete list that's populated when an you send an email to
I have a type ahead text field, and when the user hits Enter I
I have a slight issue with getting Auto Complete to search when the text
I have a form with an auto-complete field that uses jQuery Tokeninput . The
I have Auto completed text view,i want to filter the items present in the
I have used the jquery auto complete plugin in my rails application and things
I have installed Eclipse Indigo and the auto-complete feature is working normally in the
I have a project that require me to do a auto complete search using
Guys i am very new to jQuery. I have started using the auto complete
For a website, I will have a lot of auto complete fields on differents

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.