【问题标题】:select picker bootstrap change noneSelectedText选择选择器引导更改 noneSelectedText
【发布时间】:2015-10-21 08:39:38
【问题描述】:

如果没有选择,是否可以更改选择选择器的消息。目前,“未选择任何内容”已写入。我知道, noneSelectedText 属性包含该消息。

但我不想在 bootstrap.select.js 中更改它。我想动态更改它,因为我在不同的位置使用不同的选择器。

编辑:

谢谢你,它有效:)

【问题讨论】:

    标签: javascript jquery twitter-bootstrap select


    【解决方案1】:

    title 属性设置为您的选择。

    <select multiple title="Empty" class="selectpicker">
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
    </select>
    
    <select multiple title="No Value" class="selectpicker">
        <option>1</option>
        <option>2</option>
        <option>3</option>
    </select>
    
    $('.selectpicker').selectpicker();
    

    JSFiddle

    【讨论】:

    • 你好,与selectpicker下拉类相关,默认颜色为灰色,如何将灰色改为透明色?
    【解决方案2】:

    在 -this 的帮助下,我试过了。

    第一步 - 我们必须在 Html 选择标签中添加data-none-selected-text 属性。 示例 -

    <select name="your_sel_name" multiple class="form-control selectpicker" data-selected-text-format="count" data-none-selected-text >
    

    第二步 - 在 页面加载 的 js 中使用 noneSelectedText 选项
    示例 -

    $(".selectpicker").selectpicker({
            noneSelectedText : 'Please Select' // by this default 'Nothing selected' -->will change to Please Select
        });
    

    希望对某人有所帮助,谢谢!

    【讨论】:

    • 我只是在
    • 我只使用了第二步,也为我工作:)
    【解决方案3】:

    在我的例子中,我只需要添加这个 HTML 代码:

    data-none-selected-text="please select..."
    

    定义&lt;select&gt;时,我的工作代码:

    <select name="..." class="..." data-none-selected-text="please select...">
    <option>...</option>                    
    </select>
    

    【讨论】:

      【解决方案4】:

      可以使用html的content属性动态加载内容值content : "No Value selected"

      【讨论】:

        猜你喜欢
        • 2019-08-23
        • 2013-06-22
        • 1970-01-01
        • 2014-12-15
        • 1970-01-01
        • 2013-11-28
        • 2020-10-20
        • 1970-01-01
        • 2017-12-23
        相关资源
        最近更新 更多