gpt4 book ai didi

javascript - 使用 Bootstrap Switch 设置输入的 labelText

转载 作者:行者123 更新时间:2023-11-28 15:08:14 24 4
gpt4 key购买 nike

描述:

我浏览了 Bootstrap Switch 的 documentation但不太清楚我应该如何更改开关输入的 labelText。

Name      | Attribute      | Type  | Description                             | Values | Default
----------+----------------+-------+-----------------------------------------+--------+--------
labelText | data-label-text| String| Text of the center handle of the switch | String| ' '

它应该是这样的:

label on text label off text

我明白了,只是“标签”区域没有文本。

我尝试过的:

我可以这样设置默认的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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com