Untitled
unknown
plain_text
13 days ago
3.0 kB
3
Indexable
<!DOCTYPE html> <html lang="ms"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Project NILAM Sekolah</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; text-align: center; margin: 0; padding: 20px; } .container { max-width: 500px; margin: auto; background: white; padding: 20px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); border-radius: 8px; } input, textarea, button { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ccc; border-radius: 5px; } button { background: #28a745; color: white; font-size: 16px; cursor: pointer; border: none; } button:hover { background: #218838; } .book-list { text-align: left; margin-top: 20px; } .book { background: #e9ecef; padding: 10px; margin-top: 10px; border-radius: 5px; } </style> </head> <body> <div class="container"> <h2>Project NILAM Sekolah</h2> <p>Daftar buku yang telah dibaca:</p> <input type="text" id="title" placeholder="Tajuk Buku" required> <input type="text" id="author" placeholder="Penulis" required> <textarea id="summary" rows="3" placeholder="Ringkasan Buku" required></textarea> <button onclick="addBook()">Tambah Buku</button> <div class="book-list" id="bookList"></div> </div> <script> function addBook() { let title = document.getElementById('title').value; let author = document.getElementById('author').value; let summary = document.getElementById('summary').value; if (title === '' || author === '' || summary === '') { alert("Sila lengkapkan semua maklumat!"); return; } let bookList = document.getElementById('bookList'); let bookDiv = document.createElement('div'); bookDiv.classList.add('book'); bookDiv.innerHTML = ` <strong>${title}</strong> oleh <em>${author}</em> <p>${summary}</p> <button onclick="removeBook(this)">Padam</button> `; bookList.appendChild(bookDiv); // Kosongkan input document.getElementById('title').value = ''; document.getElementById('author').value = ''; document.getElementById('summary').value = ''; } function removeBook(button) { button.parentElement.remove(); } </script> </body> </html>
Editor is loading...
Leave a Comment