通过select下拉框里的value控制div显示与隐藏

简介: 通过select下拉框里的value控制div显示与隐藏
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
    </head>
    <script>
        $(function() {
            //隐藏div
            $("#shouhou2").hide();
            $("#shouhou3").hide();
            //给div添加change事件
            $("#type").change(function() {
                if($(this).val() == 1 ) {
                    $("#shouhou1").show();
                    $("#shouhou2").hide();
                    $("#shouhou3").hide();
                } else if($(this).val() == 2 ) {
                    $("#shouhou2").show();
                    $("#shouhou1").hide();
                    $("#shouhou3").hide();
                }
                else if($(this).val() == 3 ) {
                    $("#shouhou3").show();
                    $("#shouhou1").hide();
                    $("#shouhou2").hide();
                }
            })
        })
    </script>
    <body>
        <select class="select" size="1" name="type" id="type">
            <option value="1">表格</option>
            <option value="2">折线图</option>
            <option value="3">柱状图</option>
        </select>
        <div id="shouhou1" style>表格区域</div>
        <div id="shouhou2" style>折线图区域</div>
        <div id="shouhou3" style>柱状图区域</div>
    </body>
</html>
相关文章
|
10月前
隐藏el-table-column过多的内容并进行浮窗展示
隐藏el-table-column过多的内容并进行浮窗展示
隐藏el-table-column过多的内容并进行浮窗展示
|
20天前
|
JavaScript
Element_select 选择器 选中框中显示不了选中的值
解决Vue中`el-select`选择器不显示选中值的问题:在`selectChanged`方法中添加`this.$forceUpdate()`,强制组件更新,使输入框显示选择的值。示例代码包括模板和方法。
|
2月前
el-select如何自定义下拉选项框的宽度
el-select如何自定义下拉选项框的宽度
114 0
|
10月前
layui表单select框同时支持下拉和输入的解决方案
layui表单select框同时支持下拉和输入的解决方案
186 0
|
6月前
|
JavaScript
jqGrid数据列表和表单的列隐藏/显示
jqGrid数据列表和表单的列隐藏/显示
|
6月前
layUI禁用select下拉框
layUI禁用select下拉框
|
6月前
vxe-table可编辑状态默认显示下拉选select为默认展示
vxe-table可编辑状态默认显示下拉选select为默认展示
|
7月前
|
人工智能 自然语言处理 语音技术
el-select下拉框高度有效设置不污染
el-select下拉框高度有效设置不污染
226 0
|
10月前
|
缓存 JavaScript 前端开发
el-table 列的动态显示与隐藏
当我们在对表格数据查看的时候,可能某些列的数据是当前想要重点关注的,而某些列并不需要展示出来,我们就可以通过对表格的列进行实时的一个切换去实现动态的显示与隐藏。
|
11月前
|
JavaScript
Element UI - el-select(选择器)下拉多选菜单不换行显示
Element UI - el-select(选择器)下拉多选菜单不换行显示