I'm creating a table dynamically with first row as textbox . HTML
<input type="button" id="btncreate" value="create" />
<div id="htmltable">
</div>
Jquery
$(document).ready(function() {
create();
});
$(function() {
$('#btncreate').click(function() {
create();
});
$("#txtSearchPicklistNo").keyup(function() {
alert($(this).val());
});
});
function create() {
$('#htmltable').append("<table class='table table-striped table-bordered'></table>");
var table = $('#htmltable').children();
table.append("<thead>");
table.append("<tr>");
table.append("<th style='width:25px;'>SNo </th>");
table.append("<th style='width:75px;'>Picklist No</th>");
table.append("</tr>");
table.append("</thead>");
// table.append($("<td/>").html('<input type="text" class="unitprice" name="unit_price" id="unit_price"/>'));
table.append("<tbody><tr><td></td><td><input type='text' id='txtSearchPicklistNo' style='font-size: x-small; height: 13px;' /></td></tr></tbody>");
}
In the above javasript ,I have a create function which will create a table dynamically when user click on create button.In that table first row as a textbox which id as 'txtSearchPicklistNo'
The issue is keyup event is not firing when i call create function with in button click event $('#btncreate').click(function() {create(); });
. but the same function is working as much as expected when it is called from $(document).ready(function() {create();});
Please check the fiddler also, https://jsfiddle.net/King_Fisher/a7v7tc5L/2/
how do i fix this?