Home  >  Article  >  Web Front-end  >  How to set css in jq

How to set css in jq

coldplay.xixi
coldplay.xixiOriginal
2021-04-29 11:26:386368browse

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].

How to set css in jq

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn