@BoltClock有CSS答案.
如果您正在寻找跨浏览器兼容性并且您愿意使用js,则可以执行以下操作:
CSS
.last_bold{
font-weight:bold;
color:red;
padding-top:2em;
display:inline-block;
}
var a = $('.last_wfp').text();
var b = a.split('. ');
$('.last_wfp').html('' + b[0] + '' + '. ' + b[1]);
编辑
Per mr.nicksta的观察:
potentially more efficient to look for first index of a period and
then create a substring from the start to that position? and this
approach assumes only two sentences per paragraph element, any further
sentences are lost.
这是修改后的代码,应该处理任何句子.
var a = $('.last_wfp').text();
var b = a.slice(0, a.indexOf('. '));
var c = a.slice(a.indexOf('. '), a.length);
$('.last_wfp').html('' + b + '' + c);