Elementor #7959

Worry Box





    .worry-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    padding: 10px;
    width: 300px;
    z-index: 9999;
    }
    .worry-box-header {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 10px;
    }
    .worry-box-content {
    display: none;
    }
    .worry-box-content.show {
    display: block;
    }
    #close-btn {
    margin-top: 10px;
    }
    #worry-list {
    margin-top: 10px;
    list-style: none;
    padding: 0;
    }
    #worry-list li {
    padding: 5px;
    border-bottom: 1px solid #ccc;
    }
    #worry-list li:last-child {
    border-bottom: none;
    }
    const worryForm = document.getElementById(‘worry-form’);
    const worryList = document.getElementById(‘worry-list’);
    const closeBtn = document.getElementById(‘close-btn’);
    const worryBox = document.querySelector(‘.worry-box’);
    // Add worry to list when form is submitted
    worryForm.addEventListener(‘submit’, function(event) {
    event.preventDefault();
    const worryInput = document.getElementById(‘worry-input’);
    const worry = worryInput.value.trim();
    if (worry !== ”) {
    const li = document.createElement(‘li’);
    li.innerText = worry;
    worryList.appendChild(li);
    worryInput.value = ”;
    }
    });
    // Show/hide worry box
    worryBox.addEventListener(‘click’, function(event) {
    worryBox.classList.toggle(‘show’);
    });
    // Clear worry list and hide worry box
    closeBtn.addEventListener(‘click’, function(event) {
    worryList.innerHTML = ”;
    worryBox.classList.remove(‘show’);
    });