开发者

why creating a style element doesn't work? [duplicate]

开发者 https://www.devze.com 2023-02-26 06:41 出处:网络
This开发者_如何学JAVA question already has answers here: Closed 11 years ago. Possible Duplicate:
This开发者_如何学JAVA question already has answers here: Closed 11 years ago.

Possible Duplicate:

Creating a CSS class in jQuery

$("< style>span{color:red}< /style>");


jQuery < span>jQuery< /span> jQuery


Heh, interesting idea.

This works if you insert the element into the DOM:

 $('head').append($("<style>span{color:red}</style>"));

jsFiddle

Dynamically fiddling with CSS usually has some side effects, but this should okay: It works fine even in IE6.


$("<style>span{color:red}</style>").appendTo('head'); ?

0

精彩评论

暂无评论...
验证码 换一张
取 消