我想做的是使用jQuery在一個段落中查找一段文本并添加一些CSS以使其變?yōu)榇煮w。我似乎無法弄清楚為什么這行不通:$(window).load(function() {// ADD BOLD ELEMENTS$('#about_theresidency:contains("cross genre")').css({'font-weight':'bold'});});動態(tài)地提取“ about_theresidency”中的文本,因此在加載窗口后執(zhí)行該文本。
3 回答

有只小跳蛙
TA貢獻1824條經(jīng)驗 獲得超8個贊
嘗試:
$(window).load(function() {
// ADD BOLD ELEMENTS
$('#about_theresidency:contains("cross genre")').each(function(){
$(this).html(
$(this).html().replace(/cross genre/g,'<strong>$&</strong>')
);
});
});
添加回答
舉報
0/150
提交
取消