$('<style></style>').text('css').appendTo('head') does not work in IE?
- by powerboy
It works fine in Firefox and Chrome, but does not work in IE8. Here is the html structure:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
// this does not work in the stupid IE
$('<style type="text/css"></style>').text('body {margin: 0;}').appendTo('head');
});
</script>
</head>
<body>
</body>
</html>
And what' s the alternative to do this in IE?