Changing text of dynamically added element
<p>After creating a new html element </p>

<pre><code>$('select#base_element').append('&lt;option value="new_option" id="option_'+id+'"&gt;New option&lt;/option&gt;');
</code></pre>

<p>How do I do:</p>

<pre><code>$('#option_'+id).text('new text');
</code></pre>

<p>id is a global variable that get updated each time a new option is added</p>

<p>Below is full example of what I'm trying to do:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script src="jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var id = 0;
function addOption() {
    $('#myselect').append('&lt;option id="option_'+id+'" value="blah"&gt;blah '+id+'&lt;/option&gt;');
    $('#buttons').append('&lt;input type="button" onclick="changeText('+id+');" value="Change text of option '+id+'" /&gt;');
    id += 1;
}

function changeText(target_id) {
        alert('Change Text clicked');
    $('#option_'+id).text('New text for option '+target_id);
}

$(function() {
    addOption();
    addOption();
    addOption();
});
&lt;/script&gt;
&lt;head&gt;
&lt;body&gt;
&lt;select id="myselect"&gt;

&lt;/select&gt;
&lt;div id="buttons"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
