我有这个班级class = "good"
。我需要用字符串替换它,比如style="word-wrap: break-word" width="400px"
。整个字符串class = "good"
,字符串为style="word-wrap: break-word" width="400px"
。我的实验find_all
和replace_with
不允许我使用所需的功能。无论如何可以实现吗?
答案 0 :(得分:0)
这里不需要查找和替换,因为您需要更改此元素的属性而不是任何数据或html。
使用此
$('.good').css('word-wrap', 'break-word').attr('width','400px').removeAttr('class');