dimanche 30 mai 2021

I am not able to add CSS to elements when appended using append in JQuery

I have added all the codes used which is bugging a lot

Below is the code

<div id="notCompleted">
            <h3> Not Completed</h3>
            <div class="tasks" id="1">
                <input type="checkbox">
                <label> I have a bike</label>
            </div>
        </div>

Below is JQuery

var taskNumber = 0;

    function insertTask(d) {

        if ($("#plainText").val() != '') {

            $("#notCompleted").append('<div class="tasks" id="' + taskNumber + '">',
                '<input type="checkbox">',
                '<label>' + d + '</label>',
                '</div>');
            $("#plainText").val('');
            taskNumber++;
            console.log(taskNumber);
            console.log(d);
        }

    }

Below is CSS

.tasks{
    margin: 5px 5px;
    border-radius: 5px;
    background-color: rgb(141, 190, 145);
}



Aucun commentaire:

Enregistrer un commentaire