Having an issue with replacing text in multiple elements while hovering only one element
I tried doing document.getElementsbyClassName()
but it didnt seem to work
function replace(text) {
var display = document.getElementById('head');
display.innerHTML = "";
display.innerHTML = text;
}
function revert(text) {
var display = document.getElementById('head');
display.innerHTML = "";
display.innerHTML = text;
}
<h2 id="head" onmouseover="replace('oh no!! the heading is gone')" onmouseout="revert('e8')"> e8 </h2>
<p id="pp"> :) </p>
I can replace the header but not the paragraph.
` change when the `
` is hovered? Because it's the *next* element? Because it's the next *`
`* element? Because it has an ID of `"pp"`? The question needs more detail. What does the other element's text become? The same as the `
`'s?
– Tyler Roper Aug 02 '19 at 19:32would have the text from h2, and h2 would have a different text. Exiting out would revert everything to the original text
– granbraan Aug 03 '19 at 00:42