0

I'm building my first little jquery To Do List, each list item has a checkbox, and when this is checked it is moved to the Done div. This works as expected, it's just that the checkbox is always unchecked. I've experimented with .prop() but it doesn't seem to have any affect.

Here is the HTML:

    <div class="form-container">
        <h2>To Do</h2>
        <form name="checkListForm">
        <input class="entry" type="text" name="checkListItem"/>
        <div id="button">Add!</div>
        </form>
    </div>
    <div class="list"></div>     
    <div class="done_name">Done
            <div class="done"></div>
    </div>

And the JQuery:

$('input[name=checkListContainer]').toggle(
    function () {
        $(".done_name").show();
        $(this).prop("checked", "checked");
        $(this).parents('.item_container').appendTo(".done");
        },
        function () {   
                $(this).parents('.item_container').appendTo(".list");
                    $(".done:empty").parent().hide();
        });
   });

1 Answers1

3

.prop("checked") is a true/false value:

$(this).prop("checked", true);
Matt Zeunert
  • 14,721
  • 6
  • 47
  • 77
  • 1
    Hi, thanks for the answer - I'd already tried that, with the same result ie. nothing happens, the checkbox remains unchecked. – Dibergio Feb 04 '13 at 13:57
  • @user2039559 Can you create a jsFiddle? I've been trying to get the code working without throwing an error, but I'm not sure what exactly it's supposed to do. – Matt Zeunert Feb 04 '13 at 14:13
  • Firstly, sorry - I hadn't posted the entire code. So I've created a jsFiddle and it seems getting it to check is the least of my problems. http://jsfiddle.net/Dibergio/wbRSR/ Most of the code was written within CodeAcademy, which seems to behave differently. Am going to start again in a proper environment. – Dibergio Feb 04 '13 at 17:38