Home  >  Article  >  Web Front-end  >  Example of adding row styles to divs using jQuery

Example of adding row styles to divs using jQuery

小云云
小云云Original
2018-01-10 09:55:471009browse

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. This article mainly introduces in detail the relevant methods of adding row styles to a certain p using jQuery. It has certain reference value. Interested friends can refer to it. I hope it can help you.

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>

Rendering:

Change the font color to Red:

Related recommendations:

jQuery click anywhere except the specified area to hide the DIV function

jQuery implements detailed explanation of swapping positions of buttons in two divs

jQuery loads an html page into the specified div

The above is the detailed content of Example of adding row styles to divs using jQuery. 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