Jump to content
  • 0

как загрузить в localStorage? Что бы при перезагрузке страницы данные оставались


Valera001
 Share

Question

Заранее спасибо

Вот код

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Exam</title>
    <link rel="stylesheet" href="css/style.css">
    <script
            src="https://code.jquery.com/jquery-3.4.1.js"
            integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
            crossorigin="anonymous">
    </script>
</head>
<body>
<style>
    .ToDo {
        display: inline-block;
        margin-right: 30px;
    }
    .field {
        width: 240px;
        border: 2px solid black;
    }
    .btn {
        border: 2px solid black;
        outline: none;
        cursor: pointer;
        background: #FFffff;
        box-shadow: 3px 3px 1px -1px rgba(0, 0, 0, 0.75);

    }
    .btn:active {
        background: wheat;
    }
    .main-column {
        display: flex;
    }
    .column-item {
        margin-right: 30px;
        width: 250px;
        text-align: center;
    }
    .title {
        border: 2px solid black;
        padding: 1px 50px;
        margin-bottom: 5px;
    }
    .column {
        border:2px solid black;
        height: auto;
        padding: 12px 0;
    }
    #card {
        border: 2px solid black;
        background: gray;
        width: 130px;
        padding: 0 0 7px 15px;
        margin: 0 auto 5px;

    }
    .card-txt {
        display: inline-block;
        padding-right: 21px;
    }
    .card-delete {
        margin: 0 10px 30px 0;
        display: inline-block;
        outline: none;
        cursor: pointer;
        background: transparent;
        border: none;
    }
    #card-btn {
        border: 2px solid black;
        outline: none;
        cursor: pointer;
        background: #FFffff;
        box-shadow: 3px 3px 1px -1px rgba(0, 0, 0, 0.75);
    }
    #card-btn:active {
        background: wheat;
    }
</style>
<p class="ToDo">Create new To Do: <input type="text" class="field"></p>
<button class="btn">Add</button>


<div class="main-column">
    <div class="column-item">
        <p class="title">To Do</p>
        <div class="first-column column">

        </div>
    </div>

    <div class="column-item">
        <p class="title">In Progress</p>
        <div class="second-column column">

        </div>
    </div>

    <div class="column-item">
        <p class="title">Done</p>
        <div class="third-column column">

        </div>
    </div>
</div>

<script>


    $('.btn').on('click', function () {
        var column = $('.first-column');
        var field = $('.field').val();
        var div = $('<div id = "card">');
        var txt = $('<p class="card-txt"></p>');
        txt.html(field);
        var buttonD = $('<button class="card-delete"><b>X</b></button>');
        var inProgress = $('<button id="card-btn">In Progress ></button>');
        div.append(txt, buttonD, inProgress);
        column.append(div);
        buttonD.on('click', function () {
            div.remove()
        });
        inProgress.on('click', function () {
            var secondColumn = $('.second-column');
            secondColumn.append(div)
            inProgress.html('Done >');
            inProgress.on('click', function () {
                var thirdColumn = $('.third-column');
                thirdColumn.append(div);
                inProgress.html('Delete')
            })

        })

    });
</script>
</body>
</html>
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy