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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:30:30+00:00 2026-05-21T18:30:30+00:00

Most of the code works as expected, but I’m getting some unusual behavior under

  • 0

Most of the code works as expected, but I’m getting some unusual behavior under a very specific circumstance that I’m totally confused about…

I’m moving elements from div to div depending on the class of the one that is picked. I’ve got all of that working…

I’m now trying to implement an input field that will take a value, create an <li> element out of it, and append it to another div. I’ve got that working as well.

The problem that I’m having is I keep getting an extra blank li added if I click out of the input field and then back in it and add something… I can see (in the jsfiddle link) that it’s inserting 2 commas, and that’s likely why I’m getting an additional blank li, but I can’t pinpoint where that’s happening…

I’m trying to achieve the following:

  1. A user enters text into the input
    field and hits enter. <– works
  2. An
    <li> element is created (with a
    class of “oon”) and appended to
    ul#selected. <– works
  3. If a user
    clicks on <li class="oon">, it is
    removed <– works

The Problem

  1. I click in an input field and
    enter some text and hit enter. If I
    stay in the input field and keep
    typing values and hitting enter, it
    always works as expected.
  2. I click on another element with the
    class “addable”. That gets appended
    as expected.
  3. I return to the
    input field and enter some text and
    hit enter. Now, what I typed in is
    appended just as it is in Problem
    (1), but it also adds on an
    additional li element with an empty
    id and no text

Per someone’s comment, I posted the code here:
http://jsfiddle.net/vvF7v/11/

  • 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-21T18:30:31+00:00Added an answer on May 21, 2026 at 6:30 pm

    You’re re-binding the keypress event every time a user clicks an ‘li’. So each time you go through your steps 1-3, it keeps adding to the number of blank ‘li’s being appended.

    Try this:

     $('input#add-oon').unbind('keypress').keypress(function(e) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code below works, but I know it can't be the most efficient. Is
I have two controllers which share most of their code (but must be, nonetheless,
this c# code is probably not the most efficient but gets what I want
I've gone through most of the example code and I still need some help.
I have an intermittent problem with some code that writes to a Windows Event
So, I have a code, that compiled on MSVC 9 and some previous (dunno
Maybe I'm being misled by my profiler (Netbeans), but I'm seeing some odd behavior,
I am using protobuf now for some weeks, but I still keep getting exceptions
What is the most code free way to decode a string: \xD0\xAD\xD0\xBB\xD0\xB5\xD0\xBA\xD1\x82\xD1\x80\xD0\xBE\xD0\xBD\xD0\xBD\xD0\xB0\xD1\x8F to human
Which is the most correct code? if (HttpContext.Current.Response.Cookies[authCookieName] != null) { HttpContext.Current.Response.Cookies[authCookieName].Value = New

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.