<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>select.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery/jquery-1.4.2.js"></script>
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
$(function(){
for(var i=0;i<20;i++)
{
$("#select").append("<option type='类型"+i+"' value='变量"+i+"'>显示"+i+"</option>");
}
});
function showMessage(){
alert($("#select option:selected").text());
}
function showType(){
alert($("#select option:selected").attr("type"));
}
function showValue(){
alert($("#select option:selected").val());
}
</script>
</head>
<body>
<select id="select"></select><br/>
<button onclick = "showMessage()">获取显示信息</button></br/>
<button onclick = "showType()">获取类型信息</button></br/>
<button onclick = "showValue()">获取变量信息</button></br/>
</body>
</html>
JQuery获取select参数
最新推荐文章于 2023-03-31 11:18:47 发布