1.
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 4 <html> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> 7 <title>为不同HTML元素分配相同类名并应用样式</title> 8 <link rel="stylesheet" href="common.css" type="text/css" /> 9 <script src="jquery-1.5.2.js" type="text/javascript"></script> 10 <script type="text/javascript"> 11 $(document).ready( function() { 12 //jQuery使用addClass()方法给元素添加多个class样式的方法 13 $('.features').addClass('highlight'); 14 }); 15 </script> 16 </head> 17 <body> 18 <h2 class="features"> 19 This is h2 title text content! 20 </h2> 21 <p class="features"> 22 A paragraph of text! 23 </p> 24 </body> 25 </html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>为不同HTML元素分配相同类名并应用样式</title>
<link rel="stylesheet" href="common.css" type="text/css" />
<script src="jquery-1.5.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready( function() {
//jQuery使用addClass()方法给元素添加多个class样式的方法
$('.features').addClass('highlight');
});
</script>
</head>
<body>
<h2 class="features">
This is h2 title text content!
</h2>
<p class="features">
A paragraph of text!
</p>
</body>
</html>