Jquery <select></select>

楚洋
2023-12-01
<!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>
    <title></title>
    <style type="text/css">
        select
        {
            width: 100px;
            height: 200px;
        }
    </style>
    <script src="jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#btn').click(function () {
                //alert($('#Select1 option:selected').text());
                //alert($('#Select1 :checked').text());
                //alert($('#Select1 option:checked').text());
                //alert($('#Select1').val());
                //alert($('#Select1').text());
            })
        })
    </script>
</head>
<body>
    请选择放假天数<select id="Select1"size="4">
        <option value="1">9天</option>
        <option value="2">7天</option>
        <option value="3">3天</option>
        <option value="4">不放</option>
    </select>
    请选择放假天数<select id="Select2" size="4" multiple="multiple">
        <option value="1">9天</option>
        <option value="2">7天</option>
        <option value="3">3天</option>
        <option value="4">不放</option>
    </select>
    <input type="button" value="选择放假天数" id="btn" />
    <div id="divshow">
    </div>
</body>
</html>
 类似资料: