JavaScript or jQuery can be used to rearrange li elements for mobile view

Is there a way to rearrange the li elements only on mobile view and not on desktop using JavaScript or jQuery? Below is the code snippet and image for reference.

Any assistance would be greatly appreciated!

The tab order in desktop view remains:

https://i.sstatic.net/NzXGC.png

Only on mobile view, we need to reorder from this:

https://i.sstatic.net/0pBp7.png

to this:

https://i.sstatic.net/ggqLM.jpg

Answer №1

To create a responsive design, consider using two separate lists: one for desktop and one for mobile. Assign the classes desktop-view and mobile-view to these lists respectively. Then, employ media queries in your CSS to control the visibility of each class based on screen size.

.mobile-view{visibility:hidden}
.desktop-view{visibility:hidden}

// Show Mobile View
@media screen and (max-width: 599px) {
    .mobile-view{visibility:visible}
}

// Show Desktop View
@media screen and (min-width: 600px) {
    .desktop-view{visibility:visible}
}

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

The term "post" is not recognized within the Node.js environment

Utilizing a Google Cloud VM instance to host my node app on Ubuntu 16.04.6. Node.js v11.10.1 and npm v6.7.0 are installed, but encountering a ReferenceError: post is not defined when running the app with node app. Package.json file: {"name": "name", "ve ...

The margins within the div of the new tab are not applying as expected

Greetings! Currently, I am in the process of generating a dynamic form within a new tab using JavaScript. For some reason, the margin effects on the div element are not being applied correctly. Despite my attempts to set the margins using both classes and ...

What are the steps to ensure that the content within the <pre><code></code></pre> tags displays correctly in Internet Explorer 7?

When using JQuery to make an AJAX pull with JSON to an ASP.net Web Service, the following code is used: $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "TestWebService.asmx/Foo", data: "{}", dataType: "json", success: function( ...

Display alternative component upon button click in React.js

After creating the default layout, I'm aiming for a scenario where clicking each button only alters specific parts of the layout through the content component. React router is being utilized to manage different pages. Each button corresponds to a uni ...

Guide on displaying React Native code within a React app on a web browser

Instead of creating media queries in my website built with React.JS or Next.JS and an app in React Native, can I display the entire app UI and functionality on mobile and tablet viewports? Please note that my inquiry is not related to code sharing. My ex ...

Issues with jQuery .click and .html functions not functioning as expected

Does anyone have experience creating a game with jQuery? I can't seem to get the options after the first choice to work. Sorry, I don't have a working example at the moment. --- jQuery --- $(document).ready(function() { $(".console"). ...

Executing Javascript in Python Environment

I'm currently working on developing an HTML document parser using Python. Since I have a strong understanding of jQuery, I am interested in leveraging its traversal capabilities to parse these HTML files and then send the gathered data back to my Pyth ...

Picking a singular item from a group

Within my GridView, I have included an <asp:Label> with the ID of "Description" and CssClass set to "dsc". In the code-behind file written in C#.NET, there is a data table containing addresses and descriptions fetched from a database. Using this data ...

Struggles encountered while configuring React

I'm in need of assistance with setting up React, even though I have both Node and npm installed. When I enter the following command: npx create-react-app new-test-react --use-npm I encounter the following error message: npm ERR! code ENOTFOUND npm E ...

Steps for linking a keypress to trigger a specific action

I need help creating a script that will redirect to a URL when a button is clicked. Below is the code I have developed. HTML : <a id="#next" href="example.com">↵</a> <a id="#previous" href="example.com">↳</a> JS : $(document ...

Resizing the Vue page to fit the viewport and using Flexbox to anchor the footer to the bottom

My Vue.js page structure consists of a navigation bar, main body content, and a footer: <template> <div class="flex_container"> <div class="container_navigation"> <nav-bar /> </div> < ...

Combining a string-based array in JavaScript

I need to remove an item from a string indexed array. Take a look at this sample code: var arr = new Array(); arr[0] = "Zero"; arr[1] = "One"; arr[2] = "Two"; arr.splice(1, 1); for (var index in arr) document.write ...

What is the most efficient method for encoding and decoding extensive volumes of data for a JavaScript user?

Currently, I am in the process of developing a standalone Javascript application using Spine and Node.js to create an interactive 'number property' explorer. This application allows users to select any number and discover its various properties s ...

Encountered a null error while utilizing ES6 computed state in React components

In my .jsx file, I am encountering an issue with the following code block: <tr> {!isEmpty(content) && content.map(o => { if(o.sortKey){ console.log(this.state[`order${o.sortKey}`]) } })} </tr> After making chan ...

Prevent css from reverting to its original rotation position

I attempted to style the navigation list with the following CSS: #navlist:hover #left-arrow { border-top: 10px solid white; position: relative; transform: translateX(120.2px) rotate(180deg); } Would it be better to use jQuery for the rotation ...

"Using CSS to align content in a table-row format on an HTML display

I'm struggling to align two components using the <div display='table-cell'> method. The first component is showing a gap at the top which I want to remove in order to have them aligned perfectly. Check out the JsFiddle example here: h ...

Error 400: The onCreate Trigger function for Cloud functions is experiencing issues with HTTP requests due to errors in the request

I am encountering an issue when attempting to add a trigger for Firestore OnCreate, as the deployment fails with HTTP Error: 400 stating that the request has errors. Essentially, my goal is to write to a new document if a record is created in a different ...

having difficulty iterating through the data using map function

When attempting to use the map function in React Material UI to display an array of data in a select box, I encountered the error TypeError: Cannot read properties of undefined (reading 'map') while using the following code. Can anyone help me id ...

"Streamlining communication: Building a mail sending form with AJAX, JQuery

I am currently dealing with a dilemma on my website where I have 2 contact forms, and I am utilizing ajax jQuery to send emails via PHP. Everything works smoothly when I use a single form along with jQuery. However, when I try to adapt the jQuery code for ...

Error: The cordovaLocalNotification plugin is attempting to read a property 'plugins' that is undefined, resulting in a TypeError

I am currently working on a hybrid application using the Ionic platform. I am trying to integrate Cordova local notification features, but I keep getting an error message saying "cannot read property 'plugins' of undefined." Below is my code. Can ...