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

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