The functionality to display or conceal divs containing repeaters is not functioning properly

Having a bit of trouble trying to display one div with a slideshow and hide another containing a list of images on larger screens, like desktops. I want to do the opposite on smaller screens. Both Div's have repeater controls, but I don't think that should cause any issues. Any suggestions on why it's not working would be greatly appreciated.

Here's my jQuery code and the CSS classes I'm trying to use;

$(function () {
        $(window).resize(function () { ToggleSlideshow(); });
        ToggleSlideshow();
    });

    function ToggleSlideshow() {
        // Apply your condition here to toggle the visibility of the slide show
        if ($(window).width() < 500) {
            $("#slideShowContainer").addClass(".hiding");
        $("#imgList").addClass(".showing");
    } else {
            $("#slideShowContainer").addClass(".showing");
    $("#imgList").addClass(".hiding");
    }
    }

.showing{
display:block;
}
.hiding{
display:none;
}

When I say it's not working, I mean both are being displayed which is not what I am aiming for. You can see it live by following this link.

Answer №1

After some trial and error, I was able to make it work in the end. Here's how I managed to do it:

  $(function () {
  $(window).resize(function () { ToggleSlideshow(); });
  ToggleSlideshow();
});

function ToggleSlideshow() {
  // Display slideshow for screen widths larger than 500, otherwise show image list
  $("#<%=slideShowContainer.ClientID%>").toggle($(window).width() >= 660);
  $("#<%=imgList.ClientID%>").toggle($(window).width() < 660);
}

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 it possible to validate an email domain using node.js? For example, checking if gmail.com is a valid email domain, and ensuring that users do not enter incorrect variations such as egmail.com

I've been working with React.js and Express.js/Node.js, utilizing nodemailer for sending emails. However, I've noticed that a lot of emails are coming in with incorrect domains, such as [email protected], rather than the correct ones like [e ...

Captivating Images accompanied by Descriptive Captions

I was wondering if there is a straightforward method using only CSS and HTML to address this particular issue. I am in the process of creating a marquee that displays images within a fixed-width div. The number of images exceeds the capacity of the div, ...

Vue.js Ready event is not firing

In my Vue function, I have two methods. The first method, postStatus, is used to save a post when the user clicks on the save button. The second method, getPosts, is used to retrieve all previous posts from the database for that user. Below is the Vue.js ...

There seems to be a problem with the object as

While working with signalR hub, the variable "name" functions smoothly in all other methods except for the following one where it returns as "undefined." In this particular method, the "name" is supposed to be added to a list and eventually displayed in a ...

How to make a seamless full-width background with CSS

I'm in the process of developing a new website called WebSpace and I'm looking to extend the header background color to span from one end to the other. Currently, the layout appears like this: I want to eliminate the unnecessary white space on t ...

Utilize a standard PHP script for every subdirectory within a domain

I'm currently working on a website and the design I'm using involves changing the URL in the address bar using the history API when the page content changes through JavaScript and AJAX. However, I also want each "page" of the website to be access ...

I would like to hide the button if there are fewer than five visible

When there are less than 5 visible buttons, I want the button to be invisible. The state visible outputs 5 buttons each time. On the detail page, I would like to have the buttons invisible if there are fewer than 5 outputs. In my current code, when ther ...

Tips for handling errors in ajax calls with alternative promises

While working on an application that offers weather data based on user location coordinates, I created the code provided below (also accessible in this codepen http://codepen.io/PiotrBerebecki/pen/QNVEbP). The user's location information will be retr ...

Tips for encoding a base64 string into formats such as PDF, doc, xls, and png using jQuery, JavaScript, and HTML5

Need help handling base64 strings received from the server to save files in multiple browsers (IE, FF, Chrome). If receiving a PDF base64 string, how can it be saved in the browser? Also, if receiving an Image or Doc base64 string, what is the process fo ...

How to dynamically modify ion-list elements with Ionic on button click

Imagine having 3 different lists: List 1: bus, plane List 2: [related to bus] slow, can't fly List 3: [related to plane] fast, can fly In my Ionic Angular project, I have successfully implemented the first ion-list. How can I dynamically change th ...

Tips for entering Tamil characters in text boxes on a form field

Within my form, I have a set of text boxes. I am looking to input text in Tamil font for specific text boxes - around 5 out of the total 10 text boxes in the form. If you know how to enable Tamil font input for multiple text boxes (rather than just one as ...

Div with sidebar that sticks

I am currently working on setting up a website with a sticky sidebar. If you would like to see the page, click this link: On a specific subpage of the site, I am attempting to make an image Validator sticky, but unfortunately, it's not functioning a ...

When I clicked on the event in Javascript, the result was not what I expected

I am currently working on a web project centered around cooking recipes. In order for users to add ingredients to their recipes, they must input them one by one into a dynamic list that I am attempting to code using jQuery (AJAX). My issue arises when a u ...

CSS classes designed to mimic JavaScript object attribute-value pairs

I stumbled upon some interesting css class-value combinations within HTML tags. It seems like a specific JavaScript code is interpreting this, but it's something I haven't encountered before. I came across this on www.woothemes.com/flexslider/ (y ...

I am experiencing difficulties in installing JavaScript libraries

PS D:\React> npm i -g expo-cli npm WARN EBADENGINE Unsupported engine { npm WARN EBADENGINE package: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2d48555d42004e41446d68c7b6d717268805a6369786964 ...

Exploring the Power of Filtering Arrays in JavaScript

Currently, I am enrolled in online JavaScript courses and I'm intrigued by a particular task: In this task, we are given an initial array (the first argument in the destroyer function) followed by one or more arguments. The goal is to eliminate all e ...

Exploring ways to personalize the behavior and style of the material-ui Accordion component

There is a div container in gray with an accordion component containing only one AccordionSummary component. Below that is another div in blue. The initial view looks good (see pic #1). When the accordion is expanded: The AccordionDetails component is dis ...

In JavaScript, generate a new column when the text exceeds the height of a div

Is it possible to create a multicolumn layout in HTML that flows from left to right, rather than top to bottom? I am looking to define the height and width of each text column div, so that when the text overflows the box, a new column is automatically ge ...

Check for weaknesses in your project using NPM audit

While trying to install the npm package to retrieve the node module file, I encountered a total of 184 vulnerabilities (153 low, 1 moderate, 30 high) after running npm install. I am considering running npm audit fix to address these vulnerabilities, but ...

Collaborating with multiple forms and files in PHP using jQuery and AJAX operations

Need help with the title for this question. There are two input fields and buttons in index.php <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST"> <input type="text" class="for ...