You should try something like this:
$(body).append("<div id='mydiv'></div>");
$('#mydiv').fadeIn();
After first line executing there are mydiv
appears in DOM, so you can access it directly from your current script.
Edit (after comments)
If you want add script to you DOM using jQuery you should do it in some tricky way:
$("<script>$('#mydiv').fadeIn();</" + "script>").appendTo(document.body);
or
$("\x3Cscript>$('#mydiv').fadeIn();\x3C/script>").appendTo(document.body);
Without escaping or breaking </script>
tag it terminates the entire script.
If you have more issues with your code please refer to next answer https://stackoverflow.com/a/3603496/1430055 where you can find explanations about debugging such a dynamic script, etc.