如何应用相同的CSS属性而不使用jquery覆盖和多次?
$(function() {
$("#hello").css({
// Is there a way to apply both of these instead of having the second override the first?
"background-image" : "-webkit-gradient(linear,left top,left bottom,color-stop(0, #444444),color-stop(1, #999999))",
"background-image" : "-moz-linear-gradient(top, #444444, #999999)"
});
Run Code Online (Sandbox Code Playgroud)
});
用a分隔每个'指令' ;.
$("#hello").css({
"background-image" : "-webkit-gradient(linear,left top,left bottom,color-stop(0, #444444),color-stop(1, #999999));-moz-linear-gradient(top, #444444, #999999)"
});
Run Code Online (Sandbox Code Playgroud)
或者,将它放入一个CSS类中,并以更漂亮和可管理的方式执行:
.gradient {
-webkit-gradient(linear,left top,left bottom,color-stop(0, #444444),color-stop(1, #999999));
-moz-linear-gradient(top, #444444, #999999);
}
$("#hello").addClass("gradient");
Run Code Online (Sandbox Code Playgroud)