Reputation: 3243
I wan to fire slid
event of bootstrap carousel at carousel initialization.
I wan to run a function on slid
event
$('#carousel').on('slid', function () {
// do something…
})
The above code is working well, but when carousel init then its first carousel item dont fire slid
.
Please tell me how fire slid
on carousel init
Upvotes: 2
Views: 1864
Reputation: 10658
You can use the trigger() function to fire the slid
event after you initialize your carousel:
$('#carousel').carousel();
$('#carousel').on('slid', function () {
// do something…
})
$('#carousel').trigger('slid');
Upvotes: 2