hx-preserve

hx-preserve 属性允许你在 HTML 替换期间保持元素不变。当 htmx 更新任何祖级元素时,设置了 hx-preserve 的元素将由 id 保留。你必须在元素上设置一个不变的 id 才能使 hx-preserve 正常工作。响应需要具有相同 id 的元素,但其类型和其他属性将被忽略。

¥The hx-preserve attribute allows you to keep an element unchanged during HTML replacement. Elements with hx-preserve set are preserved by id when htmx updates any ancestor element. You must set an unchanging id on elements for hx-preserve to work. The response requires an element with the same id, but its type and other attributes are ignored.

注释

¥Notes