创建下拉选择框——Basic Combo

本文介绍了一个使用 jQuery EasyUI 实现的基本 Combo 控件示例,该控件展示了一个可自定义内容的下拉面板,包括如何设置不可编辑及必填选项,并通过点击选择不同的编程语言。

173613_LvoG_1582989.jpg

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Basic Combo - jQuery EasyUI Demo</title>
    <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../demo.css">
    <script type="text/javascript" src="../../jquery.min.js"></script>
    <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
    </head>
    <body>
    <h2>Basic Combo</h2>
    <p>Click the right arrow button to show drop down panel that can be filled with any content.</p>
    <div style="margin:20px 0"></div>
    <select id="cc" style="width:150px"></select>
    <div id="sp">
    <div style="color:#99BBE8;background:#fafafa;padding:5px;">Select a language</div>
    <div style="padding:10px">
    <input type="radio" name="lang" value="01"><span>Java</span><br/>
    <input type="radio" name="lang" value="02"><span>C#</span><br/>
    <input type="radio" name="lang" value="03"><span>Ruby</span><br/>
    <input type="radio" name="lang" value="04"><span>Basic</span><br/>
    <input type="radio" name="lang" value="05"><span>Fortran</span>
    </div>
    </div>
    <script type="text/javascript">
    $(function(){
    $('#cc').combo({
        required:true,
        editable:false 
    });<!--不可编辑,必输入字段-->
    $('#sp').appendTo($('#cc').combo('panel'));
    $('#sp input').click(function(){
    var v = $(this).val();
    var s = $(this).next('span').text();
    //设置下拉选中值以及所显示的文字
    $('#cc').combo('setValue', v).combo('setText', s).combo('hidePanel');
    });
    });
    </script>
    </body>
    </html>


转载于:https://my.oschina.net/ajian2014/blog/323276

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值