3 回答

TA貢獻1772條經驗 獲得超5個贊
您可以使用蒙版或剪輯路徑。請注意,這不是一個可靠的解決方案,因為您需要根據字體屬性和真實文本調整值:
.box {
/* the text to hide start at 90px and end at 137px */
-webkit-mask:linear-gradient(to right,#fff 90px,transparent 0 137px,#fff 0)
}
<div class="box">Lorem ispum custom test</div>
使用剪輯路徑:
.box {
/* the text to hide start at 90px and end at 137px */
clip-path: polygon(0 0, 90px 0, 90px 100%, 137px 100%, 137px 0, 100% 0, 100% 100%, 0 100%);
}
<div class="box">Lorem ispum custom test</div>

TA貢獻1806條經驗 獲得超5個贊
不幸的是,你不能用 CSS 做到這一點,但你可以用 jQuery 替換這個詞,如下所示:
jQuery(document).ready( function($){
? $('div').each(function(){
? ? var txt = $('div').text();
? ? var res = txt.replace('custom', '');
? ? $('div').text(res);
? });
});
重要提示:請記住,這將遍歷您的所有 div,因為您的 div 沒有 class 或 id 屬性

TA貢獻1833條經驗 獲得超4個贊
這就是您稍后可以使用您的數組的方式。
var strings = [];
var str = document.getElementById("par");
if (str.textContent.includes("one")){
var now = str.textContent.replace("one ", "");
str.textContent = now;
strings.push("one ")
};
console.log(strings)
<p id="par">this one is changed</p>
添加回答
舉報