0

I need to colorate url when the user visit:

This is my javascript file:

//element is my element

element.style.a:visited.backgroundColor='#FFFFFF';

But this code doesn't work. Anyone can help me?

Polly
  • 637
  • 3
  • 12
  • 25
  • using document.setAttribute https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute – Lokesh Pandey May 30 '18 at 14:06
  • but why would you? just use a the normal css functionality or toggle a class on the hover event and use the normal css functionality, there is no reason to do this. – digital-pollution May 30 '18 at 14:09
  • @digital-pollution sometimes we want to display some other UI to user depending on some kind of event. Like let's say you want to display the input text in red color if it's empty of not valid – Lokesh Pandey May 30 '18 at 14:10
  • yes do that by toggling a class element.classList.add('element-hovered-class'); – digital-pollution May 30 '18 at 14:12

0 Answers0