Skip to content
Szikszai Gusztáv edited this page Apr 5, 2015 · 1 revision

The basic differences between the native and ruby version of DOM manipulation are:

  • For element specific APIs see DOM \ Element

  • For event handling APIs see DOM \ Events

  • insertBefore is now insert_before

  • appendChild became >> and <<, this way it is easier to read:

    # Insert a new div into the body
    DOM::Element.new('div') >> DOM::Document.body
    
    # Or the other way around (is the same)
    DOM::Document.body << DOM::Element.new('div')
  • removeChild is simply remove, and remove became remove!

    # Remove an element
    DOM::Document.body.remove div
    
    # Or remove self
    div.remove!
  • textContent= and textContent are simply text= and text

    div.text = 'Test'
Clone this wiki locally