 <p>You <strong>can</strong> select it outside, but not <em>yet</em>, that <code>$.get()</code> callback takes some time to run (it has to get the data from the server, the callback happens <em>later</em>, when that finishes), so when you do this:</p> <pre><code>$('#newElement').css('background','black'); </code></pre> <p>That element isn't there <em>yet</em> (and so the selector doesn't find anything...it's running <em>before</em> that callback creating it does), you need to wait until the callback finishes before continuing any code that needs elements created by it. Like this:</p> <pre><code>$.get('menu.xml',function(data){ //create a new element with an ID called "#newElement" //kick off stuff that uses "#newElement" $('#newElement').css('background','black'); }); </code></pre>