JavaScript border-color/color styling

Dan picture Dan · Apr 12, 2010 · Viewed 37.2k times · Source

I'd like to style 'input.submit' of a form (hover effect for IE) using JS and tried the following which doesn't work unfortunately.

<!--[if IE]>
<script type="text/javascript">

// CHANGE SUBMIT STYLE
var foo = document.getElementByClass('input.submit');
foo.onmouseover = this.style.border-color='#000000'; this.style.color='#000000';
foo.onmouseout = this.style.border-color='#888888'; this.style.color='#888888';
foo.onclick = this.style.border-color='#000000'; this.style.color='#000000';

</script>
<![endif]-->

Could you please fix this for me? TIA, Dan

Answer

Max Kramnik picture Max Kramnik · Apr 12, 2010

It should be:

foo.onmouseover = function() {
    this.style.borderColor='#000000'; 
    this.style.color='#000000';
}