Steps to modify the display value of the Wordpress Elementor dropdown ul from block to grid

I have the Astra theme installed along with the Elementor plugin.

Can anyone guide me on how to change the CSS value of the dropdown ul item display from "block" to "grid"? I have tried adding custom CSS code but it's not taking effect.

.elementor-nav-menu--dropdown {
    display: grid;
    grid-template-columns: 1fr 1fr;

}

I also attempted to add jQuery at the bottom of footer.php, just above the body tag, but it didn't work. The code doesn't seem to be implemented on the website.

<script>
if($('.elementor-nav-menu--dropdown').visible{
  ($('.elementor-nav-menu--dropdown').css('display','grid')
};
</script>

In addition, when trying to add custom code through the Elementor plugin, an error message saying "$ is not a function" appears.

<script>
if($('.elementor-nav-menu--dropdown').visible{
  ($('.elementor-nav-menu--dropdown').css('display','grid')
};
</script>

Currently, the dropdown menu displays as "block" when visible, but I want to change it to "grid".

Answer №1

Elementor utilizes a jQuery library known as Smartmenus for creating the dropdown menu feature. If you wish to customize the menu's behavior, you have the option to override Smartmenus with your own code.

I discovered a solution that worked well in my scenario. I needed to modify display: block to display: flex, but I believe changing it to display: grid could also be effective.

You can refer to their documentation for instructions on adjusting other behaviors as per your requirements.

    $(".elementor-nav-menu").on("show.smapi", function (e, menu) {
        const newCSS = `
            width: auto;
            min-width: 10em;
            display: grid;
            max-width: 1000px;
            margin-left: 0px;
        `;
        menu.setAttribute("style", newCSS);
    });

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

What is the correct way to run javascript on a DOM element when ng-show is triggered?

For those who prefer shorter explanations, there's a TLDR at the end. Otherwise, here's a detailed breakdown. I have a form that consists of multiple inputs organized into different "pages" using ng-show. What I aim to achieve is when ng-show r ...

Angular JavaScript Object Notation structure

I am a beginner in AngularJS and I'm attempting to create formatted JSON based on the values of table rows (tr) and cells (td). The table rows are generated automatically. When the form is submitted, I try to create the JSON values. Once the form is ...

Adjust size of item within grid component in VueJS

I have a grid container with cells and a draggable item in a Vue project. I am trying to figure out how to resize the box inside the grid component (refer to images). https://i.stack.imgur.com/q4MKZ.png This is my current grid setup, and I would like the ...

How can I align a single button to the left side while positioning the rest of the elements to the right in Bootstrap 4?

I am attempting to align the B1 button on the left side and have the remaining elements positioned on the right side. Below is my code snippet using Bootstrap 4.1: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/b ...

Choose a single checkbox to select all options within a bs-table row

After successfully using bs-tables to pass selected rows through checkboxes, I am now faced with the challenge of sending data from all rows when just one checkbox is selected. The code below depicts my current approach for passing data of single and mul ...

Leverage a JSON variable within jQuery to showcase additional JSON variables

This code snippet is a work in progress, and there is room for improvement. The goal here is to have the content of thumb2 displayed in the #imageLoad container when a user clicks on a thumbnail inside the #placeholder DIV. Keep in mind that both Thumb and ...

Locate a JQuery element within another JQuery element

Apologies for my poor grasp of English. I am working with HTML and JavaScript. <noindex> <h1>This is h1 in noindex</h1> <div> <h1>This is h1 in noindex and in div</h1> <div> <h1>This is h1 in noindex a ...

Using jQuery to create a flawless animation

I am currently working on an animation project, and I have shared my progress on jsfiddle. Below is the code snippet I have utilized: /* JavaScript: */ var app = function () { var self = this; var allBoxes = $('.box&apos ...

Show and hide a div with the click of a button

As I embark on rebuilding a website from the ground up, I find myself pondering how to achieve a specific functionality: My goal is for another view to appear when one of two buttons is clicked. How can this be accomplished? I attempted the following app ...

Can you explain how Google highlights the specific search term within the description?

The functionality of my search engine is quite similar to how Google search works. When you search for a word, it gets highlighted in the returned results. https://i.sstatic.net/Y1vc0.png In my search engine, the searched word is enclosed in a span like ...

What are the steps to implementing React in this particular situation?

In my Django application, there is a view that presents booking data for all theaters on a specific date. Once the data is loaded, an authorized user can carry out tasks such as assigning coordinators or changing timings using ajax (jquery) and updating ...

The tooltip container is malfunctioning on tables and needs to be moved to the right side and bottom of

After adding some tooltips to a table, I encountered an issue where hovering over A9 displayed the tooltip for B21. $seatplanvisualization .= '<td class="rounded seatoccupied" data-container="body" data-toggle="tooltip2&qu ...

Unable to convert cursor to jpg format

I am facing an issue where I have a jpg file stored in the same folder as my styles.css, and I want to change the cursor on a webpage to this particular jpg file. Despite my efforts, it seems like the cursor is not changing as expected. Currently, I am us ...

How can I align text to the bottom right and left corners at the same time?

Is there a way to align text so that it appears in both the bottom right and bottom left corners of the page, functioning as a footer? For example: JANUARY (bottom left corner) / 2019 (bottom right corner) If anyone knows how to achieve this using HTML ...

Oops! The reference error was not caught: CallApi has not been declared

Recently, I encountered an issue while trying to utilize a submit button to call an API. Upon inspecting the page in Chrome, I found the following errors: Uncaught ReferenceError: CallApi is not defined Here is the code snippet that I am using: < ...

Creating identical height columns with uniform inner elements is a problem that needs to be solved with caution. The proposed solution

Issue: I need to create a responsive layout with 5 columns, each containing an image, title, and text. The goal is to align the images separately, titles together, and texts individually while ensuring that all elements in a row have the same height. Solu ...

ajax requests encounter an error stating "Unexpected character encountered"

I've developed a PHP application that utilizes an AJAX call to retrieve data from my database. The data format returned is as follows: { "5717a3873747106e60a087ec": { "_id": { "$id": "5717a3873747106e60a087ec" }, ...

Challenges with cross domain iframes

I am trying to find a way to send a message from an iframe to the parent page at regular intervals, for example: Iframe Domain = www.abc.com Parent Domain = www.xyz.com I have looked into the following resources: Cross domain iframe issue If anyone ha ...

Having trouble with updating your website asynchronously through code? In need of a detailed explanation?

Here are two Javascript functions that are used to call a python file in order to update an HTML page. The first function works perfectly fine, but the second one seems to be malfunctioning without throwing any errors. function button(key) { var xhttp ...

Bizarre CSS Transitions and Scaling Quirks in Webkit

Working on a website, you can check it out here In Chrome, some strange behavior occurs when the window reaches a certain resolution. Specifically, at 943 pixels width, white bars appear next to images when hovering over them, giving the impression that t ...