function newItem() {
    let li = $('<li></li>');
    let inputValue = $('#input').val();
    li.append(inputValue);

    if (inputValue === '') {
        alert('You must write something!');
    } else {
        $('#list').append(li);
    }

    // Crossing out an item from the list of items:

    function crossOut() {
        li.toggleClass('strike');
    }

    li.on('dblclick', crossOut);

    // Adding the delete button "X": 

    let crossOutButton = $('<crossOutButton></crossOutButton>');
    crossOutButton.append(document.createTextNode('X'));
    li.append(crossOutButton);

    crossOutButton.on('click', deleteListItem);

    function deleteListItem() {
        li.addClass('delete')
    }

    // Reordering the items:

    $('#list').sortable();
}
// Adding a new item to the list of items:
Adding a new item to the list of items.
Adding a new item to the list of items .
function newItem() {
    let li = $('<li></li>');
    let inputValue = $('#input').val();
    li.append(inputValue);
    if (inputValue === '') {
        alert('You must write something!');
    } else {
        $('#list').append(li);
    }
    function crossOut() {
        li.toggleClass('strike');
    }
    li.on('dblclick', crossOut);
    let crossOutButton = $('<crossOutButton></crossOutButton>');
    crossOutButton.append(document.createTextNode('X'));
    li.append(crossOutButton);
    crossOutButton.on('click', deleteListItem);
    function deleteListItem() {
        li.addClass('delete')
    }
    $('#list').sortable();
}
function newItem ( ) { let li = $ ( '<li></li>' ) ; let inputValue = $ ( '#input' ) . val ( ) ; li . append ( inputValue ) ; if ( inputValue === '' ) { alert ( 'You must write something!' ) ; } else { $ ( '#list' ) . append ( li ) ; } function crossOut ( ) { li . toggleClass ( 'strike' ) ; } li . on ( 'dblclick' , crossOut ) ; let crossOutButton = $ ( '<crossOutButton></crossOutButton>' ) ; crossOutButton . append ( document . createTextNode ( 'X' ) ) ; li . append ( crossOutButton ) ; crossOutButton . on ( 'click' , deleteListItem ) ; function deleteListItem ( ) { li . addClass ( 'delete' ) } $ ( '#list' ) . sortable ( ) ; }
Adding a new item to the list of items:
Adding a new item to the list of items :
// Crossing out an item from the list of items: // Adding the delete button "X":  // Reordering the items: