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

I have some code (see below) that works as expected under Python 2, but
The following code works fine in most browsers but it won't work in Internet
I have a jQuery select which works in most browsers axcept IE. The code
I will keep this quick. The attached code for the most part works i
Most JavaScript code is also syntactically valid ActionScript 3.0 code. However, there are some
I am trying to use SpinLock, but even this most basic code in a
I'm trying to call some python code using Py_CompileString() and PyEval_EvalCode() . It works
I am stumped. Normally, read.csv works as expected, but I have come across an
I have some code in my application that looks something like this: char *hash
Maybe I'm being misled by my profiler (Netbeans), but I'm seeing some odd behavior,

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.