學(xué)到的東西

  • html中<select>標(biāo)簽用法解析及如何設(shè)置select的默認(rèn)選中狀態(tài)
< script  type = "text/javascript" > 
function change(){ 
  document.getElementById("sel")[2].selected=true; 
} 
</ script > 
< select  id =  "sel" > 
< option  value = "1" >1</ option > 
< option  value = "2" >2</ option > 
< option  value = "3" >3</ option > 
</ select > 
< input  type = "button"  value = "修改"  onclick = "change()"  />```

獲取<select>標(biāo)簽選中項(xiàng)文本的js代碼為:
```swift
var  val = document.all.Item.options[document.all.Item.selectedIndex].text; 
var  i=document.getElementById('sel').options[document.getElementById('sel').selectedIndex].value;```
- 如何增加和刪除一行
```swift
<input type="button" value="增加" id="addTable"/>  
<input type="button" value="刪除" id="deleteTable"/>  
<table id="table1"></table>  
<script type="text/javascript" src="jquery-3.1.0.min.js"></script>
<script>  
$(document).ready(function(){  
    $("#addTable").click(function(){  
       var tr="<tr><td><input type=\"checkbox\" name=\"check\"/>"+  
              "</td><td>111</td><td>222</td><td>333</td></tr>";  
    $("#table1").append(tr);    
  
    });  
    $("#deleteTable").click(function(){  
        var check = document.getElementsByName("check");  
        for(var i=0;i<check.length;i++){  
            if(check[i].checked){  
                 document.getElementById('table1').deleteRow(i);  
                 i--;  
            }  
        }  
    })  
})  
</script>
    .ui-dialog-closeButton{
            background: url(img/close0.png);
        }
        .ui-dialog-closeButton:hover{
            /*hover偽類,用于設(shè)置鼠標(biāo)懸停樣式的改變*/
            background: url(img/close1.png);
        }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容