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 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
For example if I have an auto-numbered field, I add new records without specifying
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
So, I have an autocomplete dropdown with a list of townships. Initially I just
I have a long text field and what I want to do is that
I have stolen/found/used/written and edited the following widget of jQuery for a auto-completing dropdown.
I have found this example on StackOverflow: var people = new List<Person> { new
I have a table that contains a text field, there is around 3 to
I have been trying to update a text field in a form that will

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.