How can I apply a jQuery function to all elements with the same ID?

后端 未结 4 1969
旧时难觅i
旧时难觅i 2020-11-22 10:46

I am new to jQuery. I have the following code:

jQuery(document).ready(function() {
    jQuery(\'#carousel\').jcarousel();
});

It only appl

4条回答
  •  执念已碎
    2020-11-22 11:14

    You can't have more than one element with the same Id, that's why is not working. You should use class="caroussel" instead.

    jQuery(document).ready(function() {
        jQuery('.carousel').jcarousel();
    });
    

提交回复
热议问题