I have a tag A in which when clicked on, it appends another tag B to perform an action B on click. So when I click on tag B, action B is performed. However, the .on
method does not seems to be working on the dynamically created tag B.
My html and jquery for tag A is as below:
<a id="address" class="add_address btn btn-inverse btn-medium pull-right push-top">Add Shipping address</a>
$('.add_address').click(function(){
//Add another <a>
$(document).append('<a id="address" class="pull-right update btn btn-inverse btn-medium push-top">Update</a>');
})
When tag B is clicked, some action B is performed. My jquery is as below:
$('.update').on('click',function(){
//action B
});
I have some non dynamic content which has class ".update" as well. In the .on()
method above works fine for the non dynamic content, but not for the dynamic content.
How can I make it work for dynamic content?