$element.css(style);
这是有效的,但部分元素是在页面加载后动态创建的.这应该是
$element.live ('created',function() { $(this).css(style); });
我被困在创建的事件上.有任何想法吗?
>将规则添加到样式表,以便它们自动应用于新创建的元素>创建元素时链接css()方法:
$('<img id="createdImage" src="some.jpg"/>') .appendTo(document.body) .css(style);
>动态创建新的样式表:
$("<style>").text("#myNewEl { width:20px; height:30px; }").appendTo("head");