Created
June 9, 2013 14:18
-
-
Save jswhisperer/5743717 to your computer and use it in GitHub Desktop.
Edit css properties without jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // get reference to a DOM element | |
| var el = document.querySelector(".main-content"); | |
| //----Setting multiple CSS properties---- | |
| /* jQuery */ | |
| $(el).css({ | |
| background: "#FF0000", | |
| "box-shadow": "1px 1px 5px 5px red", | |
| width: "100px", | |
| height: "100px", | |
| display: "block" | |
| }); | |
| /* native equivalent */ | |
| el.style.background = "#FF0000"; | |
| el.style.width = "100px"; | |
| el.style.height = "100px"; | |
| el.style.display = "block"; | |
| el.style.boxShadow = "1px 1px 5px 5px red"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment