# Javascript: Applying Style to a Menu Link

**URL:** <https://forum.kirupa.com/t/javascript-applying-style-to-a-menu-link/247943>\
**Category:** web dev\
**Created:** [January 2, 2008, 3:44am UTC](https://forum.kirupa.com/t/javascript-applying-style-to-a-menu-link/247943 "2008-01-02T03:44:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)\
**Post date:** [January 2, 2008, 3:44am UTC](https://forum.kirupa.com/t/javascript-applying-style-to-a-menu-link/247943/1 "2008-01-02T03:44:51Z")

</div>

I’m noticing that if I use Javascript to apply a color to a text link element, all the CSS styles for that text element disappear (hover, visited, etc.). (See the function below for an example). Reapplying the stylesheet changes nothing - the text keeps the JS assigned color.

```auto

function resetStyle(elemId) {
  elem = document.getElementById(elemId);
  elem.style.color = '#FF0000';
}

```

Does anyone know of a way to apply a color to text without losing other assigned styles? It would be great if someone could explain to me why JS is able to override all other CSS styles.
