HTML DOM selected ÊôÐÔ
¶¨ÒåºÍÓ÷¨
selected ÊôÐÔ¿ÉÉèÖûò·µ»ØÑ¡ÏîµÄ selected ÊôÐÔµÄÖµ¡£
¸ÃÊôÐÔÉèÖÃÑ¡ÏîµÄµ±Ç°×´Ì¬£¬Èç¹ûΪ true£¬Ôò¸ÃÑ¡ÏѡÖС£¸ÃÊôÐԵijõʼֵÀ´×Ô <option> µÄ selected ÊôÐÔ¡£
Óï·¨
optionObject.selected=true|false
ʵÀý
±¾Àý¿É¸ü¸ÄÏÂÀÁбíÖеı»Ñ¡Ñ¡Ï
<html>
<head>
<script type="text/javascript">
function selectOrange()
{
document.getElementById("orange").selected=true;
}
</script>
</head>
<body>
<form>
Select your favorite fruit:
<select>
<option id="apple">Apple</option>
<option id="orange">Orange</option>
<option id="pineapple" selected="selected">Pineapple</option>
<option id="banana">Banana</option>
</select>
<br /><br />
<input type="button" onclick="selectOrange()" value="Select Orange">
</form>
</body>
</html>