คุณสมบัติ cite ของ HTML DOM del เกี่ยวข้องกับองค์ประกอบ HTML <del> ใช้บอกผู้ใช้ว่าทำไมข้อความบนเว็บไซต์ถึงถูกลบ โดยระบุ URL ที่อธิบายว่าทำไมข้อความนั้นถึงถูกลบ
คุณสมบัติ del cite เพิ่มความเข้าถึงได้ (accessibility) ของเว็บไซต์ เนื่องจากไม่มีสัญญาณภาพ (visual cues) แต่ช่วย screen readers ได้ คุณสมบัติ del cite ตั้งค่าหรือคืนค่าของแอตทริบิวต์ cite ของ HTML <del> element
ไวยากรณ์ (Syntax)
delObject.cite = URL
ที่นี่ URL ระบุ URL ของเอกสารที่อธิบายว่าทำไมข้อความถึงถูกลบ URL อาจเป็น relative หรือ absolute
ตัวอย่าง (Example)
<!DOCTYPE html> <html> <head>
<title>Del cite</title>
<style> #Sample{color:blue}; </style>
</head>
<body>
<h2>del cite property example</h2>
<p><del id="Del1" cite="sampleDeleted.html">Some text has been deleted</del></p>
<p>Click the below button to change the cite attribute value of the above deleted text</p>
<button onclick="citeChange()">Change Cite</button>
<p id="Sample"></p>
<script>
function citeChange() {
document.getElementById("Del1").cite = "https://example.com/deletedText.html";
document.getElementById("Sample").innerHTML = "The del cite attribute value was changed to 'https://example.com/deletedText.html'.";
}
</script> </body> </html>
ผลลัพธ์ (Output)
ผลลัพธ์ที่ได้:

เมื่อคลิกปุ่ม Change Cite:

คำอธิบายโค้ด
สร้าง <del> element ใน <p> id "Del1" cite="sampleDeleted.html":
<p><del id="Del1" cite="sampleDeleted.html">Some text has been deleted</del></p>
สร้างปุ่ม "Change Cite" ทำงาน citeChange() เมื่อคลิก:
<button onclick="citeChange()">Change Cite</button>
citeChange() ดึง <del> element เปลี่ยน cite = "https://example.com/deletedText.html" แสดงการเปลี่ยนแปลงในพารากราฟ id "Sample" ด้วย innerHTML ข้อความใน "Sample" สีน้ำเงินเพราะมี style ตาม id:
function citeChange() {
document.getElementById("Del1").cite = "https://example.com/deletedText.html";
document.getElementById("Sample").innerHTML = "The del cite attribute value was changed to 'https://example.com/deletedText.html'.";
}