首页 > 代码库 > JavaScript获取select下拉框中的第一个值

JavaScript获取select下拉框中的第一个值

JavaScript获取select下拉框中的第一个值


1、说明

      获取select下拉框中的第一个值


2、实现源码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript获取select下拉框中的第一个值</title>
<script type="text/javascript">
     /**
	  * JavaScript获取select下拉框中的第一个值
	  */
     function getFirstValOfSelect()
	 {
		 //获取select中的ID
		 var selectId = document.getElementById("select_option");
		 //获取select下拉框中第一个值
		 var selectValue = http://www.mamicode.com/selectId.options[0].value;>
3、实现结果

(1)选中第一项



(2)选中第二项