Home > Article > Web Front-end > How to change CSS styles using jQuery
You can use How to change CSS styles using How to change CSS styles using jQuery to change the CSS style, such as changing the color or changing the size of the element when performing operations. In this article, we will introduce to you the specific method of using How to change CSS styles using How to change CSS styles using jQuery to change the CSS style. Let’s take a look at the specific content.
The way to use How to change CSS styles using How to change CSS styles using jQuery to operate CSS is the CSS method. By using the CSS method, you can dynamically change the CSS when performing specific operations, such as buttons, so you can create more usable pages. .
Let’s take a look at the CSS method first
The basic syntax is as follows
$(‘选择器’).css('属性','值');
The selector specifies the class and ID.
Properties are the same as CSS properties, such as 'color' and 'font-size'.
The value will contain the value corresponding to the attribute. For example, "color" can mean "red" or "green", and 'font-size' means '20px'.
Let’s look at a specific example
Change the font size of a specific element
The code is as follows
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script> <script> $(function() { $(".big").css("font-size", "50px"); }); </script> </head> <body> <ul> <li class="big">big</li> <li>small</li> <li class="big">big</li> <li>small</li> </ul> </body> </html>
The display effect on the browser is as follows
This article ends here. For more exciting content, you can pay attention to the relevant column tutorials on the php Chinese website! ! !
The above is the detailed content of How to change CSS styles using jQuery. For more information, please follow other related articles on the PHP Chinese website!