I'm writing a javascript function to move a pointing arrow from one html element to another. "◀" displays an arrow in HTML.
The trouble is that while I can add an arrow to innerHTML I can't seem to remove the arrow from the current selection.
Here is the relevent portion of my code:
var current;
function changeArrowFunction(line) {
if (typeof current != 'undefined')
current.innerHTML = current.innerHTML.replace(" ◀","");
line.innerHTML = line.innerHTML + " ◀";
current = line;
}
I tried changing around the typeof condition or removing it completely with no sign of improvement, so it seems the problem is with replace().
" ◀"? Also it doesn't seem like you are correct defining your function, you need thefunctionkeyword before hand. Finally it looks like you are just placing it back in anyways.<i>◀</i>so you can remove() the i, which is a lot less janky than replacing innerHTML...