I have this small HTML document:
HT
You might have more luck with .html() and if that doesn't work try this.innerHtml. I did not test this however.
I do have another tip for your code however. If you want only scripts of type code you can have a single selector instead of having to check the attribute in the loop:
$("script[type=code]").each(function() {
alert($(this).html());
alert(this.innerHtml);
});