首页javascriptclassjQuery Style - 如何通过向头元素添加样式元素来创建动态样式

jQuery Style - 如何通过向头元素添加样式元素来创建动态样式

我们想知道如何通过向头元素添加样式元素来创建动态样式。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.5.2.js'></script>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
  $('head').append($("<style>span{color:red}</style>"));
});//]]>  
</script>
</head>
<body>
  <span>Test</span>
</body>
</html>