The .style.*
properties map directly onto the style
attribute, not to the applied style. For that you want getComputedStyle.
I’d give serious consideration to toggling .className
and separating the presentation from the logic entirely.
More Related Contents:
- Trying to use Javascript to add new li element to my ordered list, anyone know why this code isn’t working?
- Retrieve the position (X,Y) of an HTML element
- Force DOM redraw/refresh on Chrome/Mac
- Check if an element contains a class in JavaScript?
- How to hide a in a menu with CSS?
- How can I check if a scrollbar is visible?
- Changing CSS Values with Javascript
- What is difference between width, innerWidth and outerWidth, height, innerHeight and outerHeight in jQuery
- How to access CSS generated content with JavaScript
- Trigger CSS transition on appended element
- HTML Table with vertical rows
- Can I apply CSS to the elements within an iframe?
- link element onload
- Inject CSS stylesheet as string using Javascript
- Uncaught TypeError: Cannot read property ‘top’ of undefined
- How to get on-screen visible element objects in jQuery? [duplicate]
- How to get element by class name
- Removing element with jQuery?
- How do you read CSS rule values with JavaScript?
- Setting background-image using jQuery CSS property
- Why is the value of my input always empty if I store it in a variable?
- Changing nav-bar color after scrolling?
- AngularJS: How to run additional code after AngularJS has rendered a template?
- Is there any “on DOM change” event? [duplicate]
- Get CSS path from Dom element
- DOM / pure JavaScript solution to jQuery.closest() implementation?
- How to append a childnode to a specific position
- Simple way to get element by id within a div tag?
- Manually dispatchEvent DOMContentLoaded
- How can I reorder elements with JavaScript?