[英]Remove <br> Tags within specific div
因此,我正在與論壇一起制定自定義解決方案。 我無權編輯所有內容,但可以在頂部添加Javascript。 簡而言之,我有一個div,其中包含如下代碼:
<div class="mermaid">
graph TD;
A[ISE when booking]-->B;
B[Go to the Details tab of the Customer's profile / Employees profile]-->C;
C["Check to see if there are any strange or special characters (letters, numbers, etc)"]-->D;
D[If there are, remove them and try the booking again];
</div>
我需要它來顯示完全像這樣的其他javascript才能正常工作。
不幸的是,當我在論壇上的WYSIWYG編輯器中輸入此代碼時,它在每行之后添加了br標簽,而未在代碼中保留此標簽,因此得到:
<div class="mermaid">
<br>
graph TD;
<br>
A[ISE when booking]-->B;
<br>
B[Go to the Details tab of the Customer's profile / Employees profile]-->C;
<br>
C["Check to see if there are any strange or special characters (letters, numbers, etc)"]-->D;
<br>
D[If there are, remove them and try the booking again];
<br>
</div>
我建議的解決方案是在運行其他javascript之前,創建另一個javascript文件,該文件可以刪除“人魚” div中的所有br標簽。 有人對如何處理有任何提示嗎? 我對JQuery以及如何刪除元素有基本的了解,只是不確定如何僅在此div中定位元素。
您可以這樣:
jQuery(function($) {
$('.mermaid').find('br').each(function() {
$(this).remove();
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.