Home > Article > Web Front-end > How to set css in jq
jq How to set css: 1. Set a single style attribute, the code is [$('#test').css('background-color','red')]; 2. Set multiple attributes You can pass in an object, the code is [$('#test').css({'background].
The operating environment of this tutorial: windows7 System, css3 version, DELL G3 computer.
How to set css with jq:
If you want to set a single style attribute, you can do this
$('#test').css('background-color','red');
If you To set multiple attributes at the same time, you can pass in an object
$('#test').css({'background-color':'red','font-size':'20px'});
, which is the attribute value such as background-color. You can also use camel case backgroundColor. In this case, you do not need single quotes
You can try it yourself
jquery 设置css
Recommended related tutorials: CSS video tutorial
The above is the detailed content of How to set css in jq. For more information, please follow other related articles on the PHP Chinese website!