Using jQuery select and wrap textNode
$('p').contents()
.filter(function(){return this.nodeType === 3})
.wrap('<span />');
I eventually came up with this
Live Demo
// 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();
}
}
});
` tag with `` tag.
– Exploring Dec 08 '13 at 08:27