I want to change only a part of innerHTML with JavaScript, for example this:
Is is even possible to do something like this?
Thanks : )
HTML:
<html>
<head>
<title>Example</title>
</head>
<body>
<p id="text">This is an example</p>
<button onclick="myFunction()">Click to change 'an' to 'my'</button>
</body>
<script>
function myFunction() {
document.getElementById('text').innerHTML = /*Here I want to change only the 'an' to 'my', so it's 'This is my example'. Is there a way to do that?*/
}
</script>
</html>
Is is even possible to do something like this?
Thanks : )