I have a div inside noscript tags
<noscript>
<div id="googleImg" style="display:inline;">
</div>
</noscript>
In a ajax call success I remove the noscript tags, add an element inside the div. This is how I add the element inside;
var a = $jq("noscript").text();
$jq("noscript").remove();
$jq("body").append(a);
$jq("#googleImg").append(adwordsImg);
but I failed to put the noscript tags back around. How can I do it? I tried jquery.wrap but couldn't get it done.
PS: Reason for this is; I'm trying to implement Adwords to a website and because of caching mechanism, I can't just add the code into html and forget. I need to make some dynamic changes on some parameters. That's why I remove the noscript first and then try to put it back again.
Using .html()
will only get the content of the element. You can add the no script element around it by creating a new noscript element.
var a = $jq("noscript").text();
$jq("noscript").remove();
var noscript = document.createElement("noscript");
$jq(noscript).append(a);
$jq("body").append(noscript);
$jq("#googleImg").append(adwordsImg);