[英]jquery/javascript: replace string inside of html()?
以下變量......
var breadcrumbs = $('#trail').html();
...包含:
<href="page1/">Page 1</a> <strong>»</strong> <a href="page2">Page 2</a> <strong>»</strong> <a href="page3">Page 3</a>
如何用其他東西替換每個<strong>»</strong>
?
只是一個常規的舊replace
應該這樣做。 小心»
,它可能寫成»
在標記或什么......
breadcrumbs.replace( new RegExp("<strong>»</strong>", 'g'), "something else" );
breadcrumbs.replace("<strong>»</strong>","new string");
或者,取決於你如何編寫»字符
breadcrumbs.replace("<strong>»</strong>","new string");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.