Skip to content

Instantly share code, notes, and snippets.

@mistergraphx
Last active August 29, 2015 14:15
Show Gist options
  • Save mistergraphx/3eea267090f86a444384 to your computer and use it in GitHub Desktop.
Save mistergraphx/3eea267090f86a444384 to your computer and use it in GitHub Desktop.
Interactions between javascript and CSS From http://davidwalsh.name/ways-css-javascript-interact
// classList
myDiv.classList.add('myCssClass'); // Adds a class
myDiv.classList.remove('myCssClass'); // Removes a class
myDiv.classList.toggle('myCssClass'); // Toggles a class
// GetComputedStyle
// Get the color value of .element:before
var color = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('color');
// Get the content value of .element:before
var content = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('content');
// LazyLoading Stylesheets
curl(
[
"namespace/MyWidget",
"css!namespace/resources/MyWidget.css"
],
function(MyWidget) {
// Do something with MyWidget
// The CSS reference isn't in the signature because we don't care about it;
// we just care that it is now in the page
}
);
// Disable pointer event with css
// .disabled { pointer-events: none; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment