I can dynamically add the "select" element to the DOM, after adding it to the DOM, I want to change the html content of the last "select" (the last "select" was added dynamically), but it failed ...
(I cannot set the parameter value in param_html, because I have to set them using an ajax request later.)
<script>
$(function(){
var param_html = '<select class="params"></select>';
$("input[value='+']").click(function(){
$('#parameters').append(param_html);
$('.params :last').html('<option>aaa</option><option>keyword in profile</option><option>last tweet</option>');
});
});
</script>
<div id="parameters">
<input type="button" value="+">
<select class="params"><option>1</option><option>2</option></select>
</div>
any suggestion appreciated.
source
share