I did alot of searching and couldn’t locate an answer. This is the code
<div id="uniquediv"></div>
<script language="JavaScript">
(function($){
var srcitem = 'http://someURL_to_an_AD_tag';
$('<script/>', {
type: 'text/javascript',
src: srcitem
}).appendTo("#uniquediv");
})(jQuery);
</script>
No matter what I do (tried many diff things), the js code falls outside the “uniqueid” div. I need it IN the div because the div has padding and I need to retain that since the js I am including is an ad and I need to have padding around it.
(I completely retract my previous answer).
When you do
$("<script>")in jQuery, the script is downloaded and executed immediately. The .appendTo is likely not having any effect in that case, especially if the ad is doing document.write.document.write is probably the way to go in this case. I don’t think there is any downside really. If your ad src is static, you may even want to skip javascript entirely and just do a tag in your div.