向大家求解以下问题,谢谢大家~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<style>
body{
font-family:"Helvetical","Arial",sans-serif;
background-color:#fff;
color:#000;
}
table{
margin:auto;
border:1px solid #699;
}
caption{
margin:auto;
padding:.2em;
font-size:1.2em;
font-weight:bold;
}
th{
font-weight:normal;
font-style:italic;
text-align:left;
border:1px dotted #699;
background-color:#9cc;
color:#000;
}
th,td{
width:10em;
padding:.5em;
}
.intro{
font-weight:bold;
}
.odd{
background-color: #ffc;
}
</style>
</head>
<body>
<table>
<caption>Itinerary</caption>
<thead>
<tr>
<th>When</th><th>Where</th>
</tr>
</thead>
<tbody>
<tr>
<td>June 9th</td><td>Portland.OR</td>
</tr>
<tr>
<td>June 10th</td><td>Seattle.WA</td>
</tr>
<tr>
<td>June 12th</td><td>Sacramento.CA</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
//添加加载函数
function addLoadEvent(func){
var oldonload = window.onload;
if(typeof window.onload != "function"){
window.onload = func;
}else{
window.onload = function(){
oldonload();
func();
}
}
}
//设置表格样式
function stripeTable(){
if(!document.getElementsByTagName) return false;
var tables = document.getElementsByTagName("table");
var odd,rows;
for(var i=0;i<tables.length;i++){
odd = false;
rows = tables[i].getElementsByTagName("tr");
for(var j = 0;j<rows.length;j++){
if(odd==true){
addClass(rows[j],"odd");
odd= false;
}else{
odd = true;
}
rows[j].onmouseover = function(){ //问题1:为什么鼠标放在第一行上,第一行字体并没有加粗?
//问题2:为不能换成addClass(rows[j],"intro");控制台会提示element未定义???
this.style.fontWeight = "bold";
}
rows[j].onmouseout = function(){
this.style.fontWeight = "normal";
}
}
}
}
//增加样式
function addClass(element,value){
if(!element.className){
element.className = value;
}else{
var newClassName = element.className;
newClassName += " ";
newClassName += value;
element.className = newClassName;
}
}
addLoadEvent(stripeTable);
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<style>
body{
font-family:"Helvetical","Arial",sans-serif;
background-color:#fff;
color:#000;
}
table{
margin:auto;
border:1px solid #699;
}
caption{
margin:auto;
padding:.2em;
font-size:1.2em;
font-weight:bold;
}
th{
font-weight:normal;
font-style:italic;
text-align:left;
border:1px dotted #699;
background-color:#9cc;
color:#000;
}
th,td{
width:10em;
padding:.5em;
}
.intro{
font-weight:bold;
}
.odd{
background-color: #ffc;
}
</style>
</head>
<body>
<table>
<caption>Itinerary</caption>
<thead>
<tr>
<th>When</th><th>Where</th>
</tr>
</thead>
<tbody>
<tr>
<td>June 9th</td><td>Portland.OR</td>
</tr>
<tr>
<td>June 10th</td><td>Seattle.WA</td>
</tr>
<tr>
<td>June 12th</td><td>Sacramento.CA</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
//添加加载函数
function addLoadEvent(func){
var oldonload = window.onload;
if(typeof window.onload != "function"){
window.onload = func;
}else{
window.onload = function(){
oldonload();
func();
}
}
}
//设置表格样式
function stripeTable(){
if(!document.getElementsByTagName) return false;
var tables = document.getElementsByTagName("table");
var odd,rows;
for(var i=0;i<tables.length;i++){
odd = false;
rows = tables[i].getElementsByTagName("tr");
for(var j = 0;j<rows.length;j++){
if(odd==true){
addClass(rows[j],"odd");
odd= false;
}else{
odd = true;
}
rows[j].onmouseover = function(){ //问题1:为什么鼠标放在第一行上,第一行字体并没有加粗?
//问题2:为不能换成addClass(rows[j],"intro");控制台会提示element未定义???
this.style.fontWeight = "bold";
}
rows[j].onmouseout = function(){
this.style.fontWeight = "normal";
}
}
}
}
//增加样式
function addClass(element,value){
if(!element.className){
element.className = value;
}else{
var newClassName = element.className;
newClassName += " ";
newClassName += value;
element.className = newClassName;
}
}
addLoadEvent(stripeTable);
</script>
</body>
</html>
...全文
相关推荐
高等应用数学问题的matlab求解(pdf书本完全版)6/8
高等应用数学问题的matlab求解(pdf书本完全版)6/8 由于是自己后来整理的,所以文件较大,分成8个压缩包,分别是:高等应用数学问题的matlab求解(pdf书本完全版)之1/8~8/8.有耐心下载全了,解压即可!
隐枚举法贪心算法01规划问题求解-Greedy.m
隐枚举法贪心算法01规划问题求解-Greedy.m 如题~后者是早些时候整理他人的
青蛙换位问题编程求解~C++(速度版)
青蛙换位问题编程求解~C++(速度版) 算法设计中的回溯,逻辑强的进来看下了~ 传成exe文件啦,cpp文件的见上楼
隐枚举法贪心算法01规划问题求解-L01.m
隐枚举法贪心算法01规划问题求解-L01.m 如题~后者是早些时候整理他人的
python实现的八皇后问题
用python实现的八皇后问题求解。刚刚学习python时,用来练手写的代码。分享下~


