Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Check if the same text is repeated javascript todo-app

$('#add-items').click(function(event) {
    var item = $('#todo-list-item').val().trim();
    let itemCount = $("#list-items li").filter((i, li) => {
        let text = $(li).text().trim().toLowerCase();
        console.log(text)
    }).length;

    if (itemCount > 0) {
        alert("There is already such a task");
        return;
    }

    if (item && itemCount === 0) {
        $('#list-items').append("<li><input class='checkbox' type='checkbox'/>" + item + "<a class='remove'>x</a><hr></li>");
        $('#todo-list-item').val("");
    }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Check #text #repeated #javascript
ADD COMMENT
Topic
Name
3+5 =