admin管理员组

文章数量:1297066

  $('.carousel').carousel({
        pause: true,
        interval: false
    });

I want to initialize this in a function but it is not working.

Is there any way to do this?

FYI I tried placing it in the document.ready function.

  $('.carousel').carousel({
        pause: true,
        interval: false
    });

I want to initialize this in a function but it is not working.

Is there any way to do this?

FYI I tried placing it in the document.ready function.

Share Improve this question edited Oct 6, 2015 at 3:27 JoseM 4,3022 gold badges26 silver badges35 bronze badges asked Oct 6, 2015 at 3:19 code0789code0789 432 silver badges9 bronze badges 1
  • thanks for the edit @JoseM :) – code0789 Commented Oct 6, 2015 at 3:53
Add a ment  | 

2 Answers 2

Reset to default 7

Remember you have to load the jquery.js (library) file

and then load the bootstrap jquery file and then you custom js file.

Then call the carousel function like this

$('.carousel').carousel() // here carousel is the class of a div

add additional options like this

$( document ).ready(function(){
    $('.carousel').carousel({
      interval: 2000
    })
});

If you are including this script within the html page, take care to see that you are including this function calling near the end of the html page.

You can initialize function in anywhere in function. But when you call same function again then it will be re-initialize. So keep it mind the re-initialization functionality.

本文标签: