I have this code which adds html element to a div element by clicking the "practice button". However, when I click the submit button on the form, it does not call the "Selected Practice Option". However, my other form on the website calls the "Selected Practice Option". The code does not invoke the jQuery event of "Selected Practice Option". There are no errors in the jQuery code and the html code. Is this an error with jQuery?
/* Pratice Button Clicked Event */
- 35 $("#ob-practice").click(function(){
2 36 $("#newComboDiv").css("display","none");
2 37 $("#practiceComboDiv").css("display","inline-block");
2 38 var data = JSON.parse(localStorage.getItem('c'));
2 39 var text = "<form id='comboselect' action='#'> <select name='option-name'>";
- 40 for (var i in data){
3 41 var m = data[i];
3 42 text += "<option> " + m.name + "</option>";
3 43 }
2 44 text += "</select>"
2 45 text += "<button type='submit' value='submit'> Submit </button> </form>"
2 46 $("#combo-menu").html(text);
2 47 });
| 48 /*Selected Practice Option */
- 49 $("form").on("submit",function(e){
2 50 e.preventDefault();
2 51 var data = $('#comboselect').serializeArray();
2 52 alert("test");
2 53
2 54 });