Reputation: 209
So I am working on a custom solution with a forum. I don't have full access to edit everything, but I can add Javascript at the top. In short, I have a div with code in it that looks like this:
<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>
I need it to show up exactly like this for the other javascript to work properly.
Unfortunately, when I enter this in the WYSIWYG editor that is on the forum, it is adding br tags after every line and not maintaining this in the code, so I get:
<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>
My proposed solution is to have another javascript file that goes and removes all the br tags in this "mermaid" div before the other javascript runs. Does anyone have any tips on how to handle this? I have a basic understanding of JQuery and how to remove elements, I'm just not sure how to target elements only in this div.
Upvotes: 1
Views: 985
Reputation: 5849
You can do as such:
jQuery(function($) {
$('.mermaid').find('br').each(function() {
$(this).remove();
});
});
Upvotes: 3