Quantcast
Channel: User JohnP - Stack Overflow
Viewing all articles
Browse latest Browse all 37

Answer by JohnP for Changing element style attribute dynamically using JavaScript

$
0
0

Assuming you have HTML like this:

<div id='thediv'></div>

If you want to modify the style attribute of this div, you'd use

document.getElementById('thediv').style[ATTRIBUTE] = '[VALUE]'

Replace [ATTRIBUTE] with the style attribute you want. Remember to remove '-' and make the following letter uppercase.

Examples

document.getElementById('thediv').style.display = 'none'; //changes the displaydocument.getElementById('thediv').style.paddingLeft = 'none'; //removes padding

Viewing all articles
Browse latest Browse all 37

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>