JSFiddle - React, Tailwind, and code Playground
HTML
<h2>Birds - Norwegian Yellow Finch</h2>
<h2>Cats - Domestic Shorthaired Tabby</h2>
<h2>Dogs - Alaskan Husky Cross - altul</h2>
<!--
1. You can place this code at the end of body,
so it will be executed after all h2 tags rendering
-->
<!--
<script type="text/javascript">
var re = /^[^-]+-\s*/,
elements = document.getElementsByTagName('h2')
function processText(el) {
el.textContent = el.textContent.replace(re, '');
}
for(var i = 0, l = elements.length; i < l; i++) {
processText(elements[i]);
}
</script>
-->
<!--
2. Or place this code into external JavaScript file and include it at the end of body
<script type="text/javascript" src="/path/to/my/file.js" />
-->
JavaScript
// 3. Also you can execute it in window.onload event halder
var re = /^[^-]+-\s*/,
elements = document.getElementsByTagName('h2')
function processText(el) {
el.textContent = el.textContent.replace(re, '');
}
window.onload = function() {
for(var i = 0, l = elements.length; i < l; i++) {
processText(elements[i]);
}
};