jquery - Change class of Panel right before the click -


how can change class before animation starts/open/close panel? class changes after animation/panel opened or closed.

example: http://jsfiddle.net/0b9jppve/

actual code:

$('#accordion').find('.panel-default:has(".in")').addclass('panel-danger');  $('#accordion').on('shown.bs.collapse', function (e) {    $(e.target).closest('.panel-default').addclass(' panel-danger'); }).on('hidden.bs.collapse', function (e) {    $(e.target).closest('.panel-default').removeclass(' panel-danger'); }) 

all need change events you're listening for. events hide.bs.collapse , show.bs.collapse fire when animation starts, hidden.bs.collapse , shown.bs.collapse fire on completion.

$('#accordion').on('show.bs.collapse', function (e) {    $(e.target).closest('.panel-default').addclass(' panel-danger'); }).on('hide.bs.collapse', function (e) {    $(e.target).closest('.panel-default').removeclass(' panel-danger'); }) 

see updated fiddle


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -