最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

使用js如何实现隔行变色

来源:动视网 责编:小OO 时间:2020-11-27 19:35:22
文档

使用js如何实现隔行变色

本文实例为大家分享了js实现隔行变色的具体代码,供大家参考,具体内容如下:,";1px";);//table.style.border = ";solid 1px red";table.setAttribute(";width";,";200px";);table.setAttribute(";height";,";100px";);//添加到body中 document.body.appendChild(table);}//create table overcreateTable();<;/script>;。上面是我整理给大家的,希望今后会对有帮助。
推荐度:
导读本文实例为大家分享了js实现隔行变色的具体代码,供大家参考,具体内容如下:,";1px";);//table.style.border = ";solid 1px red";table.setAttribute(";width";,";200px";);table.setAttribute(";height";,";100px";);//添加到body中 document.body.appendChild(table);}//create table overcreateTable();<;/script>;。上面是我整理给大家的,希望今后会对有帮助。


这篇文章主要为大家详细介绍了纯js实现隔行变色效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了js实现隔行变色的具体代码,供大家参考,具体内容如下

<script type="text/javascript">
 function createTable(){
 //创建表格
 var table = document.createElement("table");
 
 //设置表格的行数
 for(var i=0;i<4;i++){
 var tr = document.createElement("tr");
 //设置表格的列数
 for( var j=0;j<5;j++){
 var td = document.createElement("td");
 tr.appendChild(td);
 //添加文本
 var txt = document.createTextNode("wkk");
 td.appendChild(txt);
 }
 
 //判断颜色的变换
 if(i%2==0){
 //添加属性(第一种)
 tr.style.backgroundColor = "#f0f";
 } else {
 tr.style.backgroundColor = "#ff0";
 }
 
 table.appendChild(tr);
 }
 
 //添加属性(第二种)
 table.setAttribute("border","1px");
 //table.style.border = "solid 1px red";
 table.setAttribute("width","200px");
 table.setAttribute("height","100px");
 
 
 //添加到body中
 document.body.appendChild(table);
 
 
 }//create table over
 
 createTable();
</script>

上面是我整理给大家的,希望今后会对大家有帮助。

相关文章:

在JavaScript中有哪些特殊数据类型

在微信小程序中如何使用request网络进行请求操作

使用NodeJS编写爬虫示例

在Angular中使用MathJax碰到哪些问题?

在ReactNative中如何使用Redux架构

在javascript中如何实现显式转换与隐式转换

文档

使用js如何实现隔行变色

本文实例为大家分享了js实现隔行变色的具体代码,供大家参考,具体内容如下:,";1px";);//table.style.border = ";solid 1px red";table.setAttribute(";width";,";200px";);table.setAttribute(";height";,";100px";);//添加到body中 document.body.appendChild(table);}//create table overcreateTable();<;/script>;。上面是我整理给大家的,希望今后会对有帮助。
推荐度:
标签: 使用 变色 实现
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top