I have a paragraph where some words are highlighted using <mark>
tag.
But when the document is ready, some of the words contains <mark>
tag inside another <mark>
tag.
i.e <mark><mark>MyWord</mark></mark>
Here is the code
`
$(document).ready(function(){
$('mark').each(function () {
if ($(this).next().is('mark')) {
$(this).next().remove();
}
});
});
</script>`
How will i delete extra mark tags so that MyWord contain single mark tag.i.e
<mark>MyWord</mark>
2
Answers
Perhaps it would be easier to use
display: contents
CSS on the mark tags, so that although they’re still in the page, the browser ignores them.