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(){ $('#box').css('color','red');//为id为box的p加入行间样式 }); </script> </head> <body> <p id="box">Jquery</p> </body> </html>
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!