代替我寫了這個代碼在這裏:JQuery..find最接近的空間和
var title = "This is my comment for my title";
title.replace(/['"`!#()_:\/\.\?]|&[^;]+;/g, '').substring(0, 20);
這讓我的前20個字符,但我想找到最接近的空間和...
如何更換我會那樣做嗎?
新手在JQuery的
現在它返回...... This is my comment f
,我想回This is my comment...
我嘗試添加以下代碼:
title = title.substr(title.indexOf(" ")) + "...";
,但它刪除This
我變量。
最接近什麼? – aarryy
你應該添加標題應該看起來像什麼之後。 – rojoca
更新了我的問題 – user1269625