JSFiddle - React, Tailwind, and code Playground
by Michel Plungjan
HTML
<p class="cat">
<a href="featured/" title="Featured" rel="category tag">Featured</a>
,
<a href="ispirazioni/" title="Isspirazioni" rel="category tag">Ispirazioni </a>
,
<a href="featured/" title="Featured" rel="category tag">Featured</a>
,
<a href="ispirazioni/" title="Isspirazioni" rel="category tag">Ispirazioni</a>
</p>
CSS
span { background-color:red}
a{text-decoration:none;}
JavaScript
// select and wrap all commas
$('.cat')
.contents()
.filter(function() {
return this.nodeType === 3 && $.trim(this.nodeValue)==",";
})
.wrap("<span class='comma' />");
// hide all links containing "Featured" as innerHTML
$(".cat").find('a:contains("Featured")').hide();
// select all visible elements
var $coll = $(".cat").children(":visible");
$coll.each(function() {
var $this = $(this);
if ($this.prop("tagName")=="SPAN") {
if ($coll.index(this)===0 ||
$this.nextAll(":visible").prop("tagName")=="SPAN") {
$(this).hide();
}
}
});