我有,有時有多個br
標籤在最後像下面驗證摘要:如何在HTML中使用JavaScript和jQuery替換「<br /><br />」與「<br />」?
<div id="ValidationSummary1" class="alert alert-error">
Last 4-digits of Social Security number does not match
the Member record on file for the Member ID number you
have entered.<br />
Date of Birth does not match the Member record on file for the Member ID
number you have entered.<br /><br />
</div>
我試圖找到任何時候有兩個br
標籤背靠背和一個像下面替換它:
$('#ValidationSummary1').replace('<br /><br />', '<br />');
我明白沒有replace()
函數。像這樣簡單的東西會有什麼替代?
可能重複:http://stackoverflow.com/questions/2145988/string-replace-in-jquery – David 2013-02-08 15:30:21
試試這個:'$( '#ValidationSummary1')取代( '
','
');' – Asdfg 2013-02-08 15:39:55
@Asdfg - jQuery本身沒有.replace()函數,這就是我發佈該問題的原因。 – 2013-02-08 15:41:44