I’m trying to build a custom menu where hovering over an item changes its colour. My issue is that changing $w.Text.html after setting it once seems to incur different sanitisation rules and the href attribute of the anchor is removed, obviously meaning the link points nowhere when clicked.
$w.onReady(function ()
{
$w(‘#test’).html = ‘
$w('#test').onMouseIn((e, $w) => {
$w('#test').html = $w('#test').html.replace('green', 'red');
console.log($w('#test').html);
}); //when called link is broken
});
This prints what I’d expect (below), however browser inspection tools reveal the href attribute is no longer present.
Currently I’m using two links of different colours and showing/hiding appropriately, but this has its own issues because the cursor can easily leave the area before the element is swapped and so mouseOut is never called to swap them back.
Many thanks.