星空网 > 软件开发 > Java

JS学习第四课

  1. 当我们删除某列表格,再添加新的一列时,它的序号该如何控制呢。这里id=oTab.tBodies[0].rows.length+1        otd.innerHTML=id++;   很关键哦。
  2. 还有一个关键点要再重复强调  tBodis【0】!!!
     1 <script type="text/javascript"> 2       window.onload=function(){ 3         var oTab=document.getElementById('tab1') 4         var obtn=document.getElementById('btn1') 5         var otex1=document.getElementById('name') 6         var otex2=document.getElementById('age') 7         var id=oTab.tBodies[0].rows.length+1 8         obtn.onclick=function(){ 9           var otr=document.createElement('tr')10     11           var otd=document.createElement('td')12           otd.innerHTML=id++;13           otr.appendChild(otd)14           15           var otd=document.createElement('td')16           otd.innerHTML=otex1.value17           otr.appendChild(otd)18           19           var otd=document.createElement('td')20           otd.innerHTML=otex2.value21           otr.appendChild(otd)22           23           var otd=document.createElement('td')24           otd.innerHTML='<a href="javascript:;">删除</a>'25           otr.appendChild(otd)26         27           otd.getElementsByTagName('a')[0].onclick=function(){28             oTab.tBodies[0].removeChild(this.parentNode.parentNode)29           }30         oTab.tBodies[0].appendChild(otr)31         }32       }33     </script>


     

  3. 不区分大小写的搜索toLowerCase()
  4. 模糊搜索   split   search   !=-1
     1 <script type="text/javascript"> 2       window.onload=function(){ 3         var otab=document.getElementById('tab1') 4         var obtn=document.getElementById('btn1') 5         var otex=document.getElementById('name') 6          7         obtn.onclick=function(){ 8           for(i=0;i<otab.tBodies[0].rows.length;i++){ 9         var stex=otex.value.toLowerCase();10         var stab=otab.tBodies[0].rows[i].cells[1].innerHTML.toLowerCase();11         var arr=stex.split(' ')12         otab.tBodies[0].rows[i].style.background=''13         for(j=0;j<arr.length;j++){14           if(stab.search(arr[j])!=-1){15               otab.tBodies[0].rows[i].style.background='yellow'16             }17           }    18         }19       }20       }21     </script>

     




原标题:JS学习第四课

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

配送业务:https://www.goluckyvip.com/tag/7189.html
培养潜力商家:https://www.goluckyvip.com/tag/719.html
FBA补货时间:https://www.goluckyvip.com/tag/7190.html
假日季销售:https://www.goluckyvip.com/tag/7191.html
电商购物:https://www.goluckyvip.com/tag/7192.html
海外疫情退单:https://www.goluckyvip.com/tag/7194.html
去日本入住酒店,东西随意用却有一个特殊“要:https://www.vstour.cn/a/411241.html
中国有哪些著名的酒店品牌。:https://www.vstour.cn/a/411242.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流