久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      javascript如何設(shè)置select值

      javascript設(shè)置select值的方法:1、原生js設(shè)置select值,代碼為【var gd2=document.getElementById("goods_name2")】;2、jquery設(shè)置select值。

      javascript如何設(shè)置select值

      本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版,DELL G3電腦。

      javascript設(shè)置select值的方法:

      1、原生js設(shè)置select值的方法

      (1)有時(shí)可能需要隱藏select,但是還得需要更改select所傳遞的值。(select的默認(rèn)選中之為第一個(gè),即下標(biāo)為0的選項(xiàng)值)

      var gd2=document.getElementById("goods_name2"); //為防止有時(shí)指定id元素不存在導(dǎo)致的異常 if(gd2) {  gd2[0].value=newvalue; }

      (2)原生js更改select選定的值

      var gd2=document.getElementById("goods_name2"); //為防止有時(shí)指定id元素不存在導(dǎo)致的異常 if(gd2) {     gd2.value=newvalue; //更改選定項(xiàng),值為select選項(xiàng)中原有值(即換一個(gè)選擇項(xiàng)) }
      var obj = document.getElementById("goods_name"); //定位id var index = obj.selectedIndex; // 選中索引 obj.options[index].value=newvalue;//更改選定項(xiàng)的原有值(產(chǎn)生了新的選擇項(xiàng))

      2、jquery設(shè)置select值的方法

      //設(shè)置select選定的值 $('#goods_name2 option:selected') .val(newvalue);

      相關(guān)免費(fèi)學(xué)習(xí)推薦:javascript視頻教程

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號