#slide20
would automatically scroll to the element that has the ID slide20
(if existing). Give your carousel an ID or class, and use the following code to slide to a certain number. For this to work, you must make sure that slide 20 is the 20th slide, depending on the implementation.
If you have 59 elements in your carousel, make sure that #slide20 opens the 20th slide.
In this example, your carousel has an ID of myCarousel
.
$(document).ready(function() {
$("#myCarousel").carousel(window.location.hash.substr(6) - 1);
});
This code is untested, but what it does is retrieving the value behind the #slide. window.location.hash returns #slide20
, but you are only interested in the 20
. You want the 7th (and more) character, and you start with an index of 0, so that'd leave you with substr(6). Substract 1 from that number, as slide1 should be the first slide, but Bootstrap counts from index 0 too.
I have not tested the code, but it should work, seeing Bootstrap's code.