[英]How can I remove these specific tags “<div><p> </p></div>” found in my article using CSS if not using jQuery
<div><p> </p></div>
- These tags has been added to my code because of a wysiwyg editor that I can't tweak or change. <div><p> </p></div>
-这些标记已添加到我的代码中,因为我无法调整或更改所见即所得的编辑器。 How can I remove it ideally using CSS or if not jQuery as it messes my layout. 我怎样才能理想地使用CSS删除它,或者如果不是jQuery则删除它,因为它会弄乱我的布局。
Here is the structure generated by the wysiwyg and I need to clean it up. 这是所见即所得的结构,我需要清理一下。 I can't change the wysiwyg editor because there are already lots of articles written using that editor.
我无法更改所见即所得的编辑器,因为已经有很多使用该编辑器编写的文章。 Only solution I can think of right now is purely frontend.
我现在能想到的唯一解决方案就是纯前端。 By the way the platform is Rails
顺便说一句,平台是Rails
Thanks! 谢谢!
In your HTML <div class="tempDiv" style="display:none"></div>
在您的HTML
<div class="tempDiv" style="display:none"></div>
And then some jQuery: 然后一些jQuery:
var crappyString = "<div><p> </p></div>";
$(".tempDiv").html(crappyString);
var sanitisedString = $(".tempDiv").text();
Related to an issue I've encoutered in the past: When jQuery parsing html - Chrome throwing net::ERR_FILE_NOT_FOUND 与我过去遇到的一个问题相关: 当jQuery解析html-Chrome抛出net :: ERR_FILE_NOT_FOUND
can't tweak or change
不能调整或更改
Sometimes it helps when you can talk to other devs: TinyMCE- Get plain text 有时,当您可以与其他开发人员交谈时,它会有所帮助: TinyMCE-获取纯文本
For SEO is better to get out wysiwyg and take by hand every article and clean it. 对于SEO来说,最好走出所见即所得并用手拿走每篇文章并进行清洁。 I get same situation in Joomla, and I do same.
我在Joomla中遇到相同的情况,我也这样做。 Is hard to make a good css/js selector to clear just div, div > p, div + br with no text.
很难使一个好的CSS / JS选择器仅清除div,div> p,div + br且没有文本。 The default wordpress editor make text more clean, try to see if is free on the market and add it on your app.
默认的wordpress编辑器使文本更整洁,尝试查看市场上是否免费,然后将其添加到您的应用中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.