HTML DOM value ÊôÐÔ

¶¨ÒåºÍÓ÷¨

value ÊôÐÔ¿ÉÉèÖûò·µ»ØÑ¡ÏîµÄÖµ¡£

µ±±íµ¥Ìá½»·¢ÉúµÄʱºò£¬Èç¹ûÕâ¸öÑ¡ÏѡÖУ¬value »áºÍ±íµ¥Ò»ÆðÌá½»¡£Ó³Éä <option> µÄ value ÊôÐÔ¡£

Óï·¨

optionObject.value=somevalue

ʵÀý

ÏÂÃæµÄÀý×Ó¿É·µ»Ø±»Ñ¡Ñ¡ÏîµÄÎı¾£º

<html>
<head>
<script type="text/javascript">
function alertValue()
  {
  var x=document.getElementById("mySelect").selectedIndex;
  alert(document.getElementsByTagName("option")[x].value);
  }
</script>
</head>
<body>

<form>
Select your favorite fruit:
<select id="mySelect">
  <option value="apple">Apple</option>
  <option value="orange">Orange</option>
  <option value="pineapple">Pineapple</option>
  <option value="banana">Banana</option>
</select>
<br /><br />
<input type="button" onclick="alertValue()" value="Alert selected value">
</form>

</body>
</html>
VUE