Say I have the following JavaScript in a HTML page
It is also possible to use span
tag instead of a
tag:
<html>
<script>
var simpleText = "hello_world";
var finalSplitText = simpleText.split("_");
var splitText = finalSplitText[0];
document.getElementById('someId').InnerHTML = splitText;
</script>
<body>
<span id="someId"></span>
</body>
</html>
It worked well for me