Skip to content

Instantly share code, notes, and snippets.

@jswhisperer
Created June 9, 2013 14:18
Show Gist options
  • Select an option

  • Save jswhisperer/5743717 to your computer and use it in GitHub Desktop.

Select an option

Save jswhisperer/5743717 to your computer and use it in GitHub Desktop.
Edit css properties without jQuery
// 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