I am using jQuery to create an html button with id "cancel". On my actual page, clicking my #edit button will successfully create my cancel button. However I am unable to then use this cancel button for future jQuery actions. Is there a solution to this?
$(document).ready(function() {
$("#edit").click(function() {
$("#button").html("<input id='cancel' type='button' value='cancel' />");
});
// Here I want to access my new button
$("#cancel").click(function() {
('p').hide();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id='button'><input id='edit' type='button' value=edit /></span>
<p>Hide me upon cancel</p>