::before通過and插入的文本::after不能被選擇也不能被復制。
我怎樣才能改變這個?
span::before {
content: "including this text";
}
<p>
If the text of this paragraph is selected and copied then all of it should be copied
<span>instead of only this part</span>.
</p>
使用 JavaScript 代替 CSS 是不可接受的。但以下 JavaScript 是可以接受的:
- 一個接受元素并回傳
::before文本的函式。 - 一個函式,獲取一個元素并將其
:: before文本放置到display:none.
uj5u.com熱心網友回復:
一個接受元素并回傳 ::before 文本的函式。
function getPseudoElementContent(selector){
return window.getComputedStyle(
selector, ':after'
);
}
一個函式,獲取一個元素并將其 :: 放在要顯示的文本之前:無
enter code here
function setPseudoElementContent(selector){
selector.classList.add("customBefore")
}
// And add in your style
.customBefore::before{
content:"" !important;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/475246.html
標籤:javascript html css
下一篇:如何遞回地物化一個字串
