removing a div element with coffeescript
coffeescript, dom
Solution
CoffeeScript is a JavaScript preprocessor, there is no additional standard library. What this means is that if you want to do DOM manipulation you would do it the same way you would in JavaScript.
You can use any JavaScript library like jQuery with CoffeeScript, alternatively you can use the `document` variable directly:
element.parentNode.removeChild(element) for element in document.getElementsByClassName('some-class')
Or (for browsers not supporting that method)
element.parentNode.removeChild(element) for element in document.getElementsByTagName('*') when element.className = 'some-class'
Or, since those identifiers are somewhat long, use block syntax:
for element in document.getElementsByTagName('*')
if element.className is 'some-class'
element.parentNode.removeChild(element)
Relevant quote from CoffeeScript.org:
The golden rule of CoffeeScript is: "It's just JavaScript". The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa).
Problem
I want to remove a `div` element with a specific `class` attribute using Coffeescript. I couldn't find any examples about DOM manipulation with Coffeescript on the Internet. How can I do this? Also any references to doing DOM would be great.