<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>Xin chào, tôi tên là <span id="editableContent" contenteditable="plaintext-only" style="border-bottom: 1px dashed #999;"> </span>!</p>
<button id="readButton">Đọc nội dung hiện tại</button>
<script src="script.js"></script>
</body>
</html>
const editableSpan = document.getElementById('editableContent');
const readButton = document.getElementById('readButton');
// 2. Định nghĩa hàm xử lý khi nút được nhấn
function readContent() {
// Lấy nội dung văn bản thuần túy bên trong thẻ span
const content = editableSpan.innerText;
// Hiển thị nội dung cho người dùng
alert('Nội dung hiện tại của SPAN là:\n\n' + content);
}
// 3. Gán sự kiện click cho nút nhấn
readButton.addEventListener('click', readContent);