Javascript replacewith

broken image
broken image

Replacing one DOM element with another is one example.

broken image

However, be prepared that other tasks will arise, and some of them may become pretty messy.

broken image

jQuery is so useful in this situation that it’s difficult to justify against using it to handle and delegate events. The majority of the time, jQuery is being used to attach click event handlers to DOM elements, which is OK.