Experts,
I am having a hard time getting jquery to modify some HTML values that is dynamically injected via an ajax response.
https://jsfiddle.net/ksa0yg9y/
I have some html on page:
<button id="test">test</button>
<div class="main"></div>
Script (simulating the html response by setting the html as static value):
$(document).on('click', '#test', function(){
$.ajax({
type: 'get',
url: '/echo/html/',
success:
function(data) {
$('.main').html('<input id="txt" type="text" name="title" value="">');
}
});
$('#txt').val('test');
});
Expected result would be for the
But as you can see from the jsfiddle, the input value remains blank.
Any help is appreciated.