Home > Web Front-end > JS Tutorial > body text

Use jQuery to add row styles to a div

巴扎黑
Release: 2017-06-22 17:44:51
Original
952 people have browsed it

This article mainly introduces in detail jQuery related methods of adding row styles to a certain p. It has certain reference value and interested friends can refer to it. At a glance

JQuery all starts with the $ symbol. Of course, you can use jQuery to replace the $ sign. They are identical and equal at the same time. () is actually a method, which can pass anonymous functions , etc. When selecting a certain p, if the id is p1, use $('#p1'). Remember to add the # sign. This is the same as the # sign we add when writing css styles.

Sample example is as follows:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head> 
  <title>基础核心</title>
 <script type="text/javascript" src="jquery-1.11.1.js"></script>
 <script type="text/javascript">
 $(function(){
 
 $(&#39;#box&#39;).css(&#39;color&#39;,&#39;red&#39;);//为id为box的p加入行间样式
 
});
 </script>
 </head>
 
 <body>
 <p id="box">Jquery</p>
 
 </body>
</html>
Copy after login

Rendering:

Change the font color to red:

The above is the detailed content of Use jQuery to add row styles to a div. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template