I'm new to jQuery and I've written this code in which I develop a form with some input buttons inside. There's a "cancel" button, which when clicked, I want the form to be removed.
Here's my code:
$(document).ready(function(){
$(".newIdea_Button").click(function(){
if (!new_idea_clicked)
{
$(document.body).append("<form>...some buttons here, one with the id cancel_idea_input</form>")
}
});
$("#cancel_idea_input").click(function(){
$('#new_idea_form').remove();
});
});
The thing is everything seems right to me but when I open the code in my browser (google chrome or firefox) nothing happens when I click the "cancel" button. but when I copy and paste the second function in the console part of google chrome, then the "cancel" button works! Can somebody please help me figure out what is wrong with my code?