Can Jquery use .hover to add a class or Child:hover to impact its parent element?

I have been searching for a solution tailored to my specific needs, and I am encountering difficulties in getting a seemingly simple jQuery code to function as expected.

Here is the link to my basic fiddle: http://jsfiddle.net/LBHxc/ (I apologize for the image not loading from its external host.)

HTML Code...

<nav class="nav-buttons">
<ul>
    <li class="nav-button"><a href="#">Services</a>

    </li>
    <li class="nav-button"><a href="#">Work</a>

    </li>
    <li class="nav-button top-menu">    <a href="#">Insight</a>

        <ul class="sub-menu">
            <li><a href="#"></a>

            </li>
            <li><a href="#"></a>

            </li>
            <li><a href="#"></a>

            </li>
        </ul>
    </li>
    <li class="nav-button"><a href="#">Contact</a>

    </li>
</ul>
</nav>

CSS Code

.nav-buttons {
float:left;
margin-top: 10px;
width: 370px;
height: 20px;
}
.nav-buttons a {
padding:0 1px 20px 0;
display:block;
color: #e4e4e4;
text-transform: uppercase;
text-decoration:none;
-webkit-transition: color .06s ease-in;
-moz-transition: color .06s ease-in;
-o-transition: color .06s ease-in;
transition: color .06s ease-in;
}

<nav class="nav-buttons">
<ul>
<li class="nav-button"><a href="#"></a>
</li>
</div>
</body>
</html>


.menu-drop-down {
background:url(www.anim-house.co.uk/images/drop-down-arrow.png) no-repeat;
background-position: 50% 26px;
}

JavaScript

$('.sub-menu').hover(

function () {
$('.top-menu a').addClass('menu-drop-down');
});

The behavior I aim to achieve is when hovering over "Insight," a dropdown box with three large buttons appears, along with a light blue arrow linking these boxes to Insight: <-- that When hovering on a sub-menu, I want the arrow to remain positioned below Insight. I have researched the limitations of child elements affecting their parents without JavaScript, but I am struggling to implement this. Any assistance would be greatly appreciated! (And please point out where I might have misstepped—after all, learning is my mission).

Answer №1

The arrow is not displaying properly on my end. It seems like you want the arrow to remain underneath when hovering over the parent link, is that correct?

I have made some changes in the fiddle, can you please take a look?

http://jsfiddle.net/LBHxc/9/

.nav-buttons li.top-menu:hover > a {
    background: url('http://www.anim-house.co.uk/images/drop-down-arrow.png') no-repeat bottom center;
}

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 deployed MVC code encountered an unexpected token "u" in the JSON at position 0

I have a MVC 5 application that is functioning well in the development environment. However, when I publish and deploy it to the testing server (or any other server), I encounter a JavaScript error when clicking on the login button: Uncaught SyntaxError ...

What is preventing me from installing socket.io?

I keep seeing an error in the console, what could be causing this? npm ERR! code 1 npm ERR! path E:\full-stack\proshop-2\socket\node_modules\utf-8-validate npm ERR! command failed npm ERR! command C:\WINDOWS\system32&bso ...

Is it possible to create a functionality in Google Sheets where a cell, when modified, automatically displays the date of the edit next to it? This could be achieved using a Google

Here is the current code snippet I have: function onEdit(e) { var range = e.range; var val = range.getValue(); var row = range.getRow(); var col = range.getColumn(); var shift = 1; var ss = SpreadsheetApp.getActiveSheet().getRange(row, (col+ ...

Equalizing the space between table headings and content

I am struggling with aligning the heading and entries in my table properly. https://i.stack.imgur.com/IYtY1.jpg My goal is to ensure that the heading and entries are perfectly aligned with each other. This is how my Table.jsx looks like: <div classNa ...

Exploring the realm of unit testing in the NestJS CQRS architecture journey

We're currently working on writing unit tests using Jest for our application and are facing difficulties in testing sagas. Specifically, we're having trouble testing the saga itself. During our unit testing process, we've encountered an iss ...

Please identify the path of chromedriver for selenium-standalone

I've encountered an issue when trying to initialize the selenium-standalone server (https://www.npmjs.com/package/selenium-standalone). The error message I receive is as follows: 14:19:09 /usr/local/lib/node_modules/selenium-standalone/bin/selenium-s ...

What are the steps to correctly shut down an ExpressJS server?

I am facing a challenge with my ExpressJs (version 4.X) server - I need to ensure it is stopped correctly. Given that some requests on the server may take a long time to complete (1-2 seconds), I want to reject new connections and wait for all ongoing req ...

What is the best way to reduce the file size of a group of PNG images for

For my game character, I have a collection of PNG files including stand.png, run1.png, run2.png. To display a series of actions on the JavaScript canvas, I need to load these images. However, the size of each .png file adds up quickly – for example, it ...

Use Tinymce to incorporate style_formats from an external source, such as a link_list

I'm attempting to load style formats from an external source, similar to how I do for link_list. However, the method that works for link_list doesn't seem to work for style_formats. Despite trying various solutions listed below, I haven't be ...

Graph your data with a stunning Fusioncharts area range graph combined with a sleek

My goal is to create a visual representation of an area range graph with a corresponding mid line. You can view the image below for reference: https://i.sstatic.net/8KDbF.png While I have successfully incorporated the low and high values, I am encounterin ...

Require assistance in accessing the second tab on a webpage using JavaScript tabs

Currently, I have a web page with two tabs that are initially hidden until the corresponding tab button is clicked. The click event is managed by jQuery. For example, let's assume that tab 1 is the default one when the page loads. Now, I am looking fo ...

Tips for customizing the appearance of a functional stateless component in Reactjs using class objects

I am looking to create a functional stateless component in ReactJs following the guidelines outlined here. const MyBlueButton = props => { const styles = { background: 'blue', color: 'white' }; return <button {...props} sty ...

Showing Sequelize validation errors in Express API: a comprehensive guide

In my Node.js/Express API with Sequelize ORM running MySQL, I have an Organization model that enforces a 2-100 character rule under validation. When this rule is violated in the first code snippet below, the err item from the catch block in the second code ...

Transfer information from a click event to a jQuery function

Having some trouble passing a C# list parameter to a jQuery method using onclick. It seems like the brackets [] and special characters in the string values are causing issues. For example, a string in the list might look like "*abc/def-". Any help would b ...

Angular and Express: Automatically redirecting to the previous page after user login

A question similar in nature can be found here, although not directly relevant to my situation. Within my Single Page Application, I am implementing PassportJS for user authentication. There are multiple routes that necessitate user login. The routing is ...

Retrieve a specific item from a JSON response using Node.js

When I receive a message from a WebSocket, the code snippet is triggered like this: ws.onmessage = (e) => { debugger if (e.data.startsWith('MESSAGE')) alert(JSON.stringify(e.data)) ImageReceived(e.data) c ...

Align a button to the left or right based on its position within the layout

On the left side, there is dynamic text and on the right side, a button is displayed as shown below: <div class="dynamic-text"> {{ dynamicText }} </div> <div class="some-button"> < ...

Guide on accessing nested objects in EJS templates

I'm attempting to extract the "info" portion from the JSON data provided below. In my code snippet, I'm using the <%= person['person_details']%> to access that specific section of the JSON. However, it only returns [Object Obje ...

Can you tell me what this code on Facebook is for?

Upon inspection of Facebook's activity in my browser, I stumbled upon the following code snippet: for (;;);{"t":"refresh"} Attempting to decipher its purpose reveals an infinite loop. Can you identify its function? ...

Exploring various templates with AngularJS Directives

Let's delve into a slightly complex topic, but I'll simplify it as much as possible for you. There is a directive in play: .directive('configuratorRows', function () { return { restrict: 'A', scope: { ...