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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:59:32+00:00 2026-06-17T13:59:32+00:00

Here’s what I’m trying to do: I have an input field one can use

  • 0

Here’s what I’m trying to do:
I have an input field one can use to add entries to a todo list. I use JQuery to display a sorted list of entries after the user clicks ‘Add’. I also made the list sortable (You can change the order by mouse drag using jQuery.) Now what I want to bold an individual list item when it is double-clicked. Somehow I’m not getting the jQuery to select the right item…

Here’s my code.

HTML:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="style.css" />
        <script type="text/javascript" src='script.js'></script>
        <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
        <title>Tadum</title>
    </head>
    <body>
     <h2>Tadum - The ToDo List</h2>

     <h3>Enter New ToDos</h3>
        <form id="addForm">
            <input type="text" name="ToDoListItem"></input>
        </form>
        <div id="button">Add!</div>
     <h3>Your ToDos</h3>
        <ol class="todolist"></ol>
    </body>
</html>

CSS:

.todolist li{
font-weight: normal;
}
.todolist {
    font-family:garamond;
    color:#cc0000;
}

Javascript

$(document).ready(function() {
    $('#button').click(function(){
        var toAdd = $('input[name=ToDoListItem]').val();
        $('.todolist').append('<li class="item">'+toAdd+'</li>');
        $('#addForm')[0].reset();
    });
    $('ol').sortable();
    $('ol').css('cursor', 'pointer');


    $('.todolist li').dblclick(function(){
       $(this).css('font-weight', 'bold'); 
    });
});

NOTE:

Somehow what works is if I replace the .list li in jQuery and in the CSS stylesheet with a simple ol. Then a doubleclick displays all items in the list (which is, of course, not what I want). But somehow I can’t figure out how to only select the individual <li> that is doubleclicked with jQuery…

(I also tried a bunch of variations on this. For example, only use ‘li’ to select the doubleclicked item or use ‘ol li’, or ‘.item li’. None of them work.)

  • 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-06-17T13:59:33+00:00Added an answer on June 17, 2026 at 1:59 pm

    You need to bind the dblclick event handler to the newly added list items, like this:

    $(document).on('dblclick', '.todolist li', function(){
        $(this).css('font-weight', 'bold'); 
    });
    

    Please note that this doesn’t toggle the style, but just makes them bold on double click. If you double click again it won’t do anything.

    Also if I may suggest some other changes to your JavaScript code: Your form can be normally submitted like any other form, for the purposes of this to do list anyways. I’ve also added a label to the HTML <form> for accessibility purposes.

    $(document).ready(function() {
        $('#addForm').submit(function(e){
            e.preventDefault();
    
            $('.todolist').append('<li class="item">' + $('#ToDoListItem').val() + '</li>');
            $(this)[0].reset();
        });
    
        $('ol').sortable().css('cursor', 'pointer');
    
        $(document).on('dblclick', '.todolist li', function() {
           $(this).css('font-weight', 'bold'); 
        });
    });
    

    HTML

    <form id="addForm">
        <label for='ToDoListItem'>Item:</label>
        <input type="text" id="ToDoListItem" />
        <button type='submit'>Add!</button>
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my problem.. I have the option to create(add) two new input fields,
I have a jquery bug and I've been looking for hours now, I can't
here is the site : http://www.notrepanorama.com at the bottom left, i use a jquery
Here is what I want to do. Use this HTML line and have the
Here are the tables I have: Table A which has entries with item and
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Here's the situation, i want to have a user that can enter time on
Here I am trying to retrieve the response from the server and display it,
Here is what I am trying to achieve in PHP: I have this string:
Here is the scenario: I have several CIFS partitions which AD-based users can mount

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.