String.prototype.strike() 將字串包裹在 <strike> 標籤中,呈現刪除線效果。注意:<strike> 在 HTML5 中已被廢棄,建議改用 <del> 或 <s> 標籤。
string.strike()
回傳 <strike>string</strike> 格式字串。
<script>
const text = 'Hello world';
console.log(text.strike());
// 輸出: <strike>Hello world</strike>
</script>
<del>:表示已刪除的內容,通常搭配 datetime 屬性。<s>:表示不再準確或相關的內容。text-decoration: line-through;避免在新專案使用 strike(),改用符合 HTML5 標準的標籤與樣式。