5. next slide 2


var main = function () {
$('.dropdown-toggle').click(function() {

$('.arrow-next').click(function() {
    var currentSlide = $('.active-slide');
    var nextSlide = $('.active-slide').next();

    if (nextSlide.length === 0) {
        nextSlide = $('.active-slide');




where is that nextslide.length getting its length from?? like i mean what would happen if i try to do this?


what would be the outcome??
thank you


Hi Tommy,

$('.active-slide') returns a JavaScript object containing a bunch of properties about the element(s) with that class, like ids and tag names, etc.. If you have $('.nonexistent') or something else that will result in nothing coming up, the object is empty. To check if something is empty (or if it exists at all) in JavaScript, finding the length of it is a very common method.
If the object returned by the selector has nothing in it (zero length), you know that the element doesn't exist, and can run code based on that.

Does this help you? :slightly_smiling: