2015-08-28 77 views
0

所以我正在開發一個論壇的自定義解決方案。我無法完全編輯所有內容,但我可以在頂部添加Javascript。總之,我有它的代碼一個div,看起來像這樣:刪除<br>特定div內的標籤

我需要它究竟出現這樣的其他JavaScript才能正常工作。

不幸的是,當我在所見即所得的編輯器是在論壇上輸入這一點,每一行後面添加BR標記和代碼不保持這一點,所以我得到:

<div class="mermaid"> 

<br> 

graph TD; 

<br> 

A[ISE when booking]--&gt;B; 

<br> 

B[Go to the Details tab of the Customer's profile/Employees profile]--&gt;C; 

<br> 

C["Check to see if there are any strange or special characters (letters, numbers, etc)"]--&gt;D; 

<br> 

D[If there are, remove them and try the booking again]; 

<br> 

</div> 

我提出的解決方案是另一個JavaScript文件,並在其他JavaScript運行之前刪除此「mermaid」div中的所有br標記。有沒有人有關於如何處理這個問題的提示?我對JQuery有一個基本的瞭解,以及如何移除元素,我只是不確定如何只在這個div中定位元素。

+6

使用'$( '美人魚 ')找到(' BR'),刪除()' – joyBlanks

+1

你可以使用''

''你需要什麼。 –
                        
                            
                                
                            
                        
                    

+2

使用$('。mermaid br')。remove(); – CodeHunter

回答

2

你可以做這樣的:。

jQuery(function($) { 
    $('.mermaid').find('br').each(function() { 
     $(this).remove(); 
    }); 
});