0

I have a function that dynamically adds an input and dropdown box when a '+' sign is clicked. However, when the dropdown is changed, the alert returns undefined. Why does it?

jQuery(document).change(".marker-drop-down", function() {       
    alert(jQuery(this).attr("id"));     
});

//functions
function addInputBox() {    
    jQuery("#insert-question-inbox").append('<div id="question-'+i+'-div">
<div id="remove-question-'+i+'" class="ui-icon ui-icon-minus remove-question"></div>
<input class="question-input" type="text" id=question-'+i+' value=question-'+i+' />
<select id="question-'+i+'-drop-down" class="maker-drop-down">
<option>Select</option><option value="multiple-choice">Multiple Choice</option>
<option value="select-all">Select all that apply</option></select><br /></div>');
    i += 1;     
}
Macsupport
  • 5,406
  • 4
  • 29
  • 45
Frank Castle
  • 335
  • 3
  • 23

1 Answers1

5

Try to use it as

$(document).on("change",".maker-drop-down", function(){        
        alert($(this).attr("id"));     
    });
Zach
  • 108
  • 8