hadis
1 month ago

done in todo list

Posted 1 month ago by hadis

I want to create a done function,this run when user click on checkbox this is what I did

function completed(id) {
    tasks.filter(t =>t.id , done=true)
    render()
}
function render() {

    document.getElementById("todos").innerHTML = ''

    tasks.map(t => {

        const htm = `<li>
            <div class="form-check">
                <label class="form-check-label" name="LA">
                    <input class="checkbox" onClick="completed('${t.id}')" type="checkbox" ${t.done ? 'checked="true"' : ''} id="checkbox">
                        <p class="todo" id="todo" ${t.done ? 'style="text-decoration:line-through"' : ''} >${t.text}</p>
                            <i class="input-helper"></i>
                </label>
            <button type="button" id="${t.id}" class="remove" onclick="removeItem('${t.id}')">remove</button></div></li>`;

        document.getElementById("todos").innerHTML += htm

    });

}

I don't know what should I do to create a line-through on text and check the chekbox?

Please sign in or create an account to participate in this conversation.