1

I need to change label of toggle button with data-on and data-off style. How can I do it? My toggle create as under html.

Sending OnSending Off

I've created button as under js code:

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

And I need to change it as under:

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

But it's not make any changes. Please help.

2
  • Please add your HTML here Commented Mar 16, 2017 at 11:33
  • <input type="checkbox" id="allOnOff" data-toggle="toggle" checked class="emailOnOff" data-size="normal" data-onstyle="success" data-offstyle="danger" data-on="Sending On" data-off="Sending Off"></th> Commented Mar 21, 2017 at 12:50

1 Answer 1

1

As you are changing label from JS you don't need to put that in HTML. You should replace your HTML with below code::

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

And keep your JS code as it is.

Working JSFIDDLE LINK:: https://jsfiddle.net/cswuL90j/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.