Skip to content Skip to sidebar Skip to footer

Changing Css "z-index" Property: "invalid Left-hand Side In Assignment"

I have an element with the onmouseover event handler which calls a function I made that is suppose to change the css property of another element and I gave that element the ID 'out

Solution 1:

Style names in Javascript use camelCase, so it should be:

document.getElementById("output").style.zIndex="-1";

- is the arithmetic subtraction operator, it can't used in identifiers.

Solution 2:

You forgot a quote, and hyphens aren't allowed in property names, so usually camelcase is used instead

<script>functionChangeZofO () {
    document.getElementById("output").style.zIndex = -1;
}
</script><divid="MyDiv"onmouseover="ChangeZofO()"></div>

Post a Comment for "Changing Css "z-index" Property: "invalid Left-hand Side In Assignment""