Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 引导切换复选框按钮标签由jquery更改_Javascript_Jquery_Twitter Bootstrap - Fatal编程技术网

Javascript 引导切换复选框按钮标签由jquery更改

Javascript 引导切换复选框按钮标签由jquery更改,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我需要改变切换按钮的标签和数据打开和关闭的风格。 我怎么做? 我的切换在html下创建 送行 我已经在js代码下创建了按钮: $("#allOnOff").bootstrapToggle({ on : "Sending On", off : "Sending Off", onstyle : "success", offstyle : "danger" }); 我需要根据以下

我需要改变切换按钮的标签和数据打开和关闭的风格。 我怎么做? 我的切换在html下创建

送行 我已经在js代码下创建了按钮:

 $("#allOnOff").bootstrapToggle({   
  on            :   "Sending On",
  off           :   "Sending Off",
  onstyle       :   "success",
  offstyle      :   "danger"        
 });
我需要根据以下内容对其进行更改:

$("#allOnOff").bootstrapToggle({
  on            :   "Custom",
  off           :   "Sending Off",
  onstyle       :   "warning",
  offstyle      :   "danger"
 });

但它不会做出任何改变。请帮助。

当您从JS更改标签时,您不需要将标签放入HTML。您应该用以下代码替换HTML

<input type="checkbox" id="allOnOff" data-toggle="toggle" checked class="emailOnOff" data-size="normal" data-onstyle="success" data-offstyle="danger">

并保持您的JS代码原样


正在使用JSFIDDLE链接

请在此处添加您的HTML