I am dynamically loading three text boxes in a page, I need to take id of text boxes when it is clicked.
$.ajax({
url: "../taxClass/getTaxClass",
type: "post",
contentType: "application/json",
dataType: "json",
success: function (data) {
var taxClassBOs = data.taxClassBOs;
$.each(taxClassBOs, function (key, value) {
$("#taxVatId").append('<div><label class="col-sm-3 control-label" for="VatId">' + value.description + '</label></div><div class="col-sm-3"><input type="text" name="vatId" value=""placeholder="' + value.title + '" id="' + value.taxClassId + '" class="form-control" /></div>');
});
}
});
I have tried this code
$('input[type="text"]').click(function () {
var id = $(this).attr('id');
alert(id);
});