jQuery Example: Bind Event to Dynamically Created HTML Element

Without messing up your JavaScript code with HTML.

Working example

Two key features in the example are:

  1. using “on()” function, which enables bind event to the dynamically created HTML element
  2. clone()” function to get necessary HTML without messing up JavaScript code

As a result you need only couple of lines to create this common feature.