Javascript 选择选择器引导程序更改 noneSelectedText
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31716151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
select picker bootstrap change noneSelectedText
提问by Makuna
Is it possible to change the message of a select picker, if nothing is selected. For now, 'Nothing selected' is written. I know, the noneSelectedText attribute contains that message.
如果未选择任何内容,是否可以更改选择选择器的消息。现在,写入“未选择任何内容”。我知道, noneSelectedText 属性包含该消息。
But I dont want to change it in the bootstrap.select.js. I want to change it dynamically, because I use different select pickers at different locations.
但我不想在 bootstrap.select.js 中更改它。我想动态更改它,因为我在不同位置使用不同的选择器。
Edit:
编辑:
Thank you, it works :)
谢谢,它有效:)
回答by Mariya Steksova
Set title
attribute to your selects.
将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();
回答by Anurag_BEHS
with help of - thisI tried it works .
借助 -这个我试过了。
1st step - we have to add data-none-selected-text
attribute in Html select tag.
example -
第一步 - 我们必须data-none-selected-text
在 Html 选择标签中添加属性。例子 -
<select name="your_sel_name" multiple class="form-control selectpicker" data-selected-text-format="count" data-none-selected-text >
2nd Step - in js on page loaduse noneSelectedText
option
example -
第二步 - 在页面加载的js 中使用noneSelectedText
选项
示例 -
$(".selectpicker").selectpicker({
noneSelectedText : 'Please Select' // by this default 'Nothing selected' -->will change to Please Select
});
Hope it will Help some-one Thanks!
希望它会帮助某人谢谢!
回答by Aman jain
You ca use content attribute of html to dynamically load the content value content : "No Value selected"
您可以使用 html 的 content 属性来动态加载内容值 content : "No Value selected"