Search code examples
javascriptcsspseudo-class

Underlining in Javascript?


Upon the realization that you can't have an inline pseudoclass -- How to write a:hover in inline CSS? -- I looked into having Javascript do the same job with the onMouseOver and onMouseOut events to simulate the :hover pseudoclass. I'm trying to remove the underline from the text when the mouse is above it. Is there a snippet of Javascript someone can offer that can do that?

I tried onMouseOver="this.style.textDecoration="none"", but I think the contrasting quotations are throwing everything off.

Any ideas?

Note: unfortunately, this effect must be achieved without the use of an external or internal stylesheet (inline only).


Solution

  • you can do this by

     onMouseOver="this.style.textDecoration='none';"