You can use the bootstraps .btn.active class and just add it to the button you want to port, and you can use jQuerys toggleClass to untie the buttons. Demo
Just noticed that twitter has a script button that you can call for this effect, here is a fixed demo with the expected results.
After looking at what you really wanted from the comment, I updated my fiddle with the results you are looking for.
I added a function that pulls the current day using the javascripts getDay method from the array and switches the corresponding day in the button group by setting the button identifier: demo
Relevant Code:
Js
function today() { var arr = ["0", "1", "2", "3", "4", "5", "6"]; //first day of the week is sunday and its index is 0 var currentDay = new Date().getDay(); return (arr[currentDay]); } var day = '[id="test' + today() +'"]'; // we take the current day from the array and add the beginning of the class name and save it in a variable $(day).button('toggle');
Andres Ilich Mar 04 2018-12-12T00: 00Z
source share