What is preventing my jQuery carousel from displaying?

I added a carousel to my website, but I'm having trouble getting it to display. Can someone help me troubleshoot?

My HTML:

            <!--Sponsor Carousel-->
              <link href="css/style.css" rel="stylesheet" media="screen">
                <ul id="flexiselDemo1">
                    <li><img src="img/logo-nyt.png" /></li>
                    <li><img src="img/logo-microsoft.png" /></li>
                    <li><img src="img/logo-ebay.png" /></li>
                    <li><img src="img/logo-hp.png" /></li>
                    <li><img src="img/logo-youtube.png" /></li>
                </ul>

                <div class="clearout"></div>

                <script type="text/javascript">

                    $(window).load(function() {
                        $("#flexiselDemo1").flexisel({
                            enableResponsiveBreakpoints: true,
                            responsiveBreakpoints: {
                                portrait: {
                                    changePoint:480,
                                    visibleItems: 1
                                },
                                landscape: {
                                    changePoint:640,
                                    visibleItems: 2
                                },
                                tablet: {
                                    changePoint:768,
                                    visibleItems: 3
                                }
                            }
                        });
                    });
                </script>
     <script type="text/javascript" src="js/jquery.flexisel.js"></script>
    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>  
            <!--End Sponsor Carousel-->

My CSS :

        #flexiselDemo1{
        display:none;

        }

        .nbs-flexisel-container {
            position:relative;
            max-width:90%;
            margin: 0 auto;
        }
        .nbs-flexisel-ul {
            position:relative;
            width:9999px;
            margin:0;
            padding:0;
            list-style-type:none;   
            text-align:center;  
        }

        .nbs-flexisel-inner {
            overflow:hidden;
            float:left;
            width:100%;
            background:#fcfcfc;
            background: #fcfcfc -moz-linear-gradient(top, #fcfcfc 0%, #eee 100%); /* FF3.6+ */
            background: #fcfcfc -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fcfcfc), color-stop(100%,#eee)); /* Chrome,Safari4+ */
            background: #fcfcfc -webkit-linear-gradient(top, #fcfcfc 0%, #eee 100%); /* Chrome10+,Safari5.1+ */
            background: #fcfcfc -o-linear-gradient(top, #fcfcfc 0%, #eee 100%); /* Opera11.10+ */
            background: #fcfcfc -ms-linear-gradient(top, #fcfcfc 0%, #eee 100%); /* IE10+ */
            background: #fcfcfc linear-gradient(top, #fcfcfc 0%, #eee 100%); /* W3C */
            border:1px solid #ccc;
            border-radius:10px;
            -moz-border-radius:50px;
            -webkit-border-radius:5px;
        }

        .nbs-flexisel-item {
            float:left;
            margin:0px;
            padding:0px;
            cursor:pointer;
            position:relative;
            line-height:0px;
        }
        .nbs-flexisel-item img {
            width: 100%;
            cursor: pointer;
            position: relative;
            margin-top: 10px;
            margin-bottom: 10px;
            max-width:100px;
            max-height:45px;
        }

        /*** Navigation ***/

        ...

My Jquery :

...

Answer №1

The issue lies in the way your JavaScript files are being loaded. They are currently loading after the entire document has been loaded, causing jQuery calls to not be recognized and leading to Runtime Errors.

Resolution: To fix this problem, rearrange the order of the following lines in your HTML file and move them to the beginning. Make sure to load jQuery first as the carousel depends on it.

<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script> 
<script type="text/javascript" src="js/jquery.flexisel.js"></script>

:)

Answer №2

Before starting the carousel, ensure that you have loaded all necessary scripts and that jQuery is loaded first. Additionally, make sure to place your CSS in the head section of the HTML document rather than in the body.

To include CSS in the head:

<link href="css/style.css" rel="stylesheet" media="screen">

For loading the scripts, consider following this structure. While they can be placed in the head section, it is recommended to place them at the end of the HTML document:


<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script> 
<script type="text/javascript" src="js/jquery.flexisel.js"></script>            
<script type="text/javascript">
    $(window).load(function() {
        $("#flexiselDemo1").flexisel({
            enableResponsiveBreakpoints: true,
            responsiveBreakpoints: {
                portrait: {
                    changePoint:480,
                    visibleItems: 1
                },
                landscape: {
                    changePoint:640,
                    visibleItems: 2
                },
                tablet: {
                    changePoint:768,
                    visibleItems: 3
                }
            }
        });
    });
</script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to set the AutoComplete control in Material-UI as mandatory?

Yesterday was a frustrating day as I attempted to set the AutoComplete control as required. Unfortunately, the API lacks a required attribute and onNewRequest doesn't trigger if the textbox is empty. Additionally, onBlur has a glitch preventing it fro ...

Change the color of the dropped div in fullcalendar

Here is the code for my customized calendar: $(renderTo).fullCalendar({ timeFormat: 'HH:mm', axisFormat: 'HH:mm', defaultView:view, firstHour: 7, firstDay: 1, titleFormat: { ...

Displaying pictures under specific conditions

I've recently completed the coding and CSS for my website after working on it for quite some time. Now, I want to enhance it by incorporating new features. The website is fully operational and generates revenue primarily through Google AdSense. I am i ...

Please verify the utilization of jQuery.ajaxSettings.xhr

var _orgAjax = jQuery.ajaxSettings.xhr; jQuery.ajaxSettings.xhr = function () { var xhr = _orgAjax(); DoSomeLogging(); return xhr; }; I came across this code snippet and I'm trying to make sense of it. Does this mean that any $.ajax(...) ...

Designing a touch-friendly scrollable space without traditional scrollbars

Looking to create a horizontal scrollable area for touch devices using just CSS. The current setup includes: .wrapper { position: absolute; left: 0; top: 0; right: 0; bottom: 0; width: 100%; height: 100%; overflow-x: scroll; overflow-y: ...

What could be causing the p tag to be displacing the parent div downwards?

Can someone help with an issue I'm having? I have two divs that are supposed to take up half of the screen each. However, when I add a p tag inside the second div, it gets pulled down. I am working on creating an HTML email, so I can only use inline s ...

Header stays fixed while the body scrolls, featuring an extensive header

Check out this quick demo to see my progress so far: http://jsfiddle.net/pawLs132/3/ fictitious "code" needed to post this question I'm looking for a way to have a fixed header that is wider than the screen, but with the text fitting neatly within ...

Techniques for implementing delay in jQuery when using .addClass and .removeClass

To introduce a delay of 200ms to the execution of .addClass and .removeClass, I need to modify the code snippet below: jQuery('.class').hover(() => jQuery('#custom').addClass('addedclass'), () => jQuery('#custom&ap ...

issue with date filtering in query

I'm currently developing a date and time filter for a database. The goal is to query results only within a specific date range selected by the user in an input field. I've written some code, but it seems like something is missing because it' ...

Using the image reference in the "href" attribute instead of a URL in the anchor tag in HTML

Take a look at my code snippet below: <a href="image_link1"> <img src="image_link1"></img> </a> I am facing a challenge where I want the image link to be the same as the href (so when the image is clicked, it opens in a popup of t ...

Avoid binding an object in Vue.js when you intend to copy it to a different data attribute

I am facing a situation where I have an object retrieved from my API and need to replicate it to another object while loading a modal. The following method achieves the duplication: this.servicesForm.services = this.team.services; // New object ...

Efficient Looping in VueJS: How to Iterate Between Two Numbers

How can I efficiently set values for select options using a loop with the v-for directive? For instance, how can I dynamically fill in years between 1900 and 2010? <option v-for="year in (1900 to 2010)" :value="year"> {{ year }} ...

Form Field Highlighting

I am currently attempting to eliminate the blue "halo" outline that appears on form elements in Firefox on OS X. I have successfully removed the halo in Safari on OS X using CSS with the following code: input { outline: none; } However, this method doe ...

Display the JSON information within a text input field using React JS

Below is the code I have written in the componentDidMount function: componentDidMount: function() { var url = document.URL; var currentId = url.substring(url.lastIndexOf('?') + 4); // Extracting the current ...

Struggling with incorporating a search feature? Encounter the error message "TypeError: data.filter is not a function"?

UPDATE: here is what console.log(data) shows. The data appears correctly, but the filtering process seems to be malfunctioning.] !https://imgur.com/a/SsEDAKj! UPDATE 2: this.state.items represents an array. I am currently working on integrating a search ...

Key to Perform Right Click

Hey, I could use a little advice window.addEventListener('keyup', function (event) { if (document.activeElement && document.activeElement.tagName === 'INPUT') { return; } switch (String.fromCharCode(event.keyCode ...

Creating a Mongoose Queue with a specific size of N

Having a model of chats, I am looking to limit the number of messages stored in the messages[] array to 100 for memory conservation. While browsing forums, I came across Capped Collection in recent articles, but it didn't quite fit my requirements. I ...

Tips for effectively scaling controllers in AngularJS

I have an Angular application that is currently structured with everything in one controller. I would like to split it into multiple controllers so that each controller can focus on specific actions rather than having a mixture of functions with different ...

Using PHP to trigger alerts with MySQL data via AJAX from a separate file

I need to notify the first page from the second one, like in the example below: <?php $sql = "SELECT table_id, on, off FROM tables"; // retrieving and populating my table with information $stmt = mysqli_prepare($dbc, $sql); mysqli_stmt_exec ...

ReactJS - Opt for useRef over useState for props substitution

Presented below is my ImageFallback component, which serves as a backup by displaying an svg image if the original one is not available. export interface ImageProps { srcImage: string; classNames?: string; fallbackImage?: FallbackImages; } const Im ...