javascript - Twitter bootstrap carousel control with one button -
javascript - Twitter bootstrap carousel control with one button -
i have tried find best solution twitter bootstrap carousel 2.3 navigation command not find any. case following. trying trigger carousel one button until haven't found right solution. know need toogle carousel classes how don't know.
here jquery using right now:
$(function () { $('.modal-carousel').carousel({ interval:2000, pause: "false" }); $('.style').click(function () { $('.modal-carousel').carousel('cycle'); console.log('starts carousel'); }); $('.stop.style').click(function () { $('.modal-carousel').carousel('pause'); console.log('stops carousel'); }); });
the button has .style class while .stop added when user click on button.
any suggestions?
you can utilize hasclass
determine stop
class on element , utilize toogle corousel state , don't have bind element twice. this
$(function () { $('.modal-carousel').carousel({ interval:2000, pause: "false" }); $('.style').click(function () { if ($(this).hasclass("stop")){ $('.modal-carousel').carousel('pause'); console.log('stops carousel'); } else { $('.modal-carousel').carousel('cycle'); console.log('starts carousel'); } }); });
javascript jquery twitter-bootstrap
Comments
Post a Comment