Sunday, December 15, 2024

Menambahkan AutoTextfield Dengan Fungsi Klik

 <!DOCTYPE html>

<html>

<head>

    <title>Menambahkan TextField</title>

</head>


<body>

    <button onclick="tambahTextField()">Tambah TextField</button>

    <div id="container"></div>


    <script>

        var count = 0;

        function tambahTextField() {

            const container = document.getElementById('container');

            const newTextField = document.createElement('div');

            newTextField.innerHTML = `<input type="text" id="textField${count}" value="${count}"><button onclick="hapusTextField(${count})">Hapus</button>`;

            container.appendChild(newTextField);

            count++;

        }


        function hapusTextField(id) {

            const textField = document.getElementById(`textField${id}`);

            textField.parentNode.removeChild(textField);

        }

    </script>

</body>


</html>

Set Cookie dan Remove Cookie dengan php vanilla.js

< html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta name = "viewport...