描述:
我浏览了 Bootstrap Switch 的 documentation但不太清楚我应该如何更改开关输入的 labelText。
Name | Attribute | Type | Description | Values | Default
----------+----------------+-------+-----------------------------------------+--------+--------
labelText | data-label-text| String| Text of the center handle of the switch | String| ' '
它应该是这样的:
我明白了,只是“标签”区域没有文本。
我尝试过的:
我可以这样设置默认的labelText:
$.fn.bootstrapSwitch.defaults.labelText = 'Label!';
但我不想将每个 bootstrapSwitch labelText 设置为“Label!”只有一个。
我尝试了 $("#my-input").labelText("Label!");
但这没有用(没想到)
问题:
如何使用 Bootstrap Switch 设置一个输入的标签文本?
最佳答案
在 HTML 中 - 只需更改“data-label-text”属性的值即可。
<input id="my-input" type="checkbox" data-label-text="Label!">
或者
在 JQuery 中
$("#my-input").siblings(".bootstrap-switch-label").text("Label!");
关于javascript - 使用 Bootstrap Switch 设置输入的 labelText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37939552/