Characteristics Exclusive to Inner Division

Currently, I am working on creating an arrow-like element that moves up when hovered over and returns to its original position when the mouse is no longer hovering. To achieve this effect, I have placed the arrow within a parent div and set up event listeners for mouseover and mouseout on the parent div. Below is the code snippet:

HTML:

<div class="outercircle">
    <div class="circle">
        <div class="innercircle"></div>
    </div>
</div>

CSS:

.outercircle {
    border: 1px solid black;
    margin-top: 80vh;
    width: 80px;
    margin-left: auto;
    margin-right: auto;
    cursor: pointer;
}

.circle {
    width: 60px;
    height: 60px;
    border: 7px solid black;
    border-radius: 50%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 20px;
}

.innercircle {

    display: inline-block;
    margin-top: 15%;
    margin-left: 24.5%;
    width: 40%;
    height: 40%;
    border-top: 7px solid black;
    border-right: 7px solid black;
    -moz-transform: rotate(135deg);
    -webkit-transform: rotate(135deg);
    transform: rotate(135deg);
}

JavaScript:

<script>
        $(document).ready(function() {
            var $outercircle = $(".outercircle");
            var $circle = $(".circle");

            $outercircle.hover(function() {
                $circle.animate({
                    marginTop: 0
                }, 200);
            });

            $outercircle.mouseout(function() {
                $circle.animate({
                    marginTop: 20
                }, 200);
            });
        })
</script>

It seems that the functionality only works when hovering over the inner circle (.innercircle), and the cursor:pointer style also applies only to .innercircle. Any assistance would be greatly appreciated. Happy holidays!

Edit: A simplified version of the code works fine on jsfiddle. Here is the full HTML and CSS in case there are any discrepancies.

HTML:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="stylz.css">
        <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <title>Thomas Urbanak</title>
        <script>
            $(document).ready(function() {
                var $outercircle = $(".outercircle");
                var $circle = $(".circle");

                $outercircle.mouseenter(function() {
                    $circle.animate({
                        marginTop: 0
                    }, 200);
                });

                $outercircle.mouseleave(function() {
                    $circle.animate({
                        marginTop: 20
                    }, 200);
                });
            })
        </script>
    </head>
    <body> 
        <div id="titlet">
            <ul id="menu">
                <li class="menu"><a href="#">home</a></li>
                <li class="menu"><a href="#">work</a></li>
                <li class="menu"><a href="#">about</a></li>
            </ul>
            <h1 class="title">BOB.BLUBLA</h1>
            <hr>
            <p class="subtitle">This is a paragraph, made up of words.</p>
        </div>
        <div class="outercircle">
            <div class="circle">
                <div class="innercircle"></div>
            </div>
        </div>
    </body>
</html>

CSS:

/*menu*/
#menu {
    font-family: "Roboto", sans;
    font-size: 20px;
}

.menu {
    display: inline-block;
}

a {
    text-decoration: none;
    color: black;
    -webkit-transition: border-bottom .15s;
    transition: border-bottom .15s;
}

a:hover {
    border-bottom: 5px solid #ff5c5c;
}

#menu, .menu {
    list-style: none;
    margin-left: 20px;
    margin-right: 20px;
    padding: 0;
}

/*title tile*/
#titlet {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    width: 100%;
}

.title {
    font-family: "titlefont", sans;
    text-align: center;
    font-size: 90px;
    margin-top: 250px;
}

hr {
    width: 20%;
    height: 7px;
    background: black;
    border: none;
    margin-top: -50px;
}

.subtitle {
    text-align: center;
    font-family: "Roboto", sans;
    font-size: 20px;
}

/*circle*/
.outercircle {
    border: 1px solid black;
    margin-top: 80vh;
    width: 80px;
    margin-left: auto;
    margin-right: auto;
    cursor: pointer;
}

.circle {
    width: 60px;
    height: 60px;
    border: 7px solid black;
    border-radius: 50%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 20px;
}

.innercircle {

    display: inline-block;
    margin-top: 15%;
    margin-left: 24.5%;
    width: 40%;
    height: 40%;
    border-top: 7px solid black;
    border-right: 7px solid black;
    -moz-transform: rotate(135deg);
    -webkit-transform: rotate(135deg);
    transform: rotate(135deg);
}

Answer №1

I suspect the issue may lie in your choice of event handlers.

Perhaps you should consider using mouseenter and mouseleave instead of hover and mouseout ?

 $(document).ready(function() {
    var $outercircle = $(".outercircle");
    var $circle = $(".circle");

    $outercircle.mouseenter(function() {
        $circle.animate({
            marginTop: 0
        }, 200);
    });

    $outercircle.mouseleave(function() {
        $circle.animate({
            marginTop: 20
        }, 200);
    });
});
.outercircle {
    border: 1px solid black;
    margin-top: 80vh;
    width: 80px;
    margin-left: auto;
    margin-right: auto;
    cursor: pointer;
}

.circle {
    width: 60px;
    height: 60px;
    border: 7px solid black;
    border-radius: 50%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 20px;
}

.innercircle {

    display: inline-block;
    margin-top: 15%;
    margin-left: 24.5%;
    width: 40%;
    height: 40%;
    border-top: 7px solid black;
    border-right: 7px solid black;
    -moz-transform: rotate(135deg);
    -webkit-transform: rotate(135deg);
    transform: rotate(135deg);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="outercircle">
    <div class="circle">
        <div class="innercircle"></div>
    </div>
</div>

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

Creating personalized Date and Time formatting on the X axis in Lightningchart JS

I have an X-axis representing time intervals in 15-second increments. ["2020-05-22 14:20:22", "173.9"] ["2020-05-22 14:20:40", "175.3"] ["2020-05-22 14:20:58", "172.4"] In my attempt to add this data to the chart, I used the following code: for(var key ...

The Flask form within the Bootstrap input-group is breaking onto a new line when viewed on mobile devices

I want the 'Go' button to remain next to the search field. It displays correctly on Desktop view, but on mobile view, the submit button wraps (breaking up the input-group). How can I prevent this? Additionally, Bootstrap is adding gray lines aro ...

Creating a fresh line using text interpolation within Angular 4 and Ionic 3

I am facing an issue with my front-end code: <p>{{ news.content }}</p> The variable news.content is stored in the Firebase DB. Is there a way to insert a new line in this text interpolation without making any changes to the front-end code (H ...

Exploring the height and overflow properties of nested div elements

Imagine a scenario where you have a fixed-size container and need all the elements to fit inside. The issue arises when some elements contain lots of text, causing the overflow to be hidden but still stretching beyond the container's height. How can t ...

unable to utilize the If - Else statement for checking element existence in Javascript

After writing a JavaScript function to create a table in both HTML and JS, I encountered an issue. When I click submit, the table is created, but if I click submit again, it creates another table. I attempted to use if-else statements in the function, but ...

The dynamically generated colgroup seems to be malfunctioning

I developed a jQuery plugin that includes functionality to adjust the width of table columns using colgroup, and enables users to resize them by dragging the headers left or right. I shared a simplified version of this plugin here. While it functions corre ...

Issue with Swiper JS: The buttons on pages three and beyond are unresponsive

I'm having trouble with the functionality of the "Back" button on pages 2 and 3 of my website. Can anyone help me figure out why it's not working? My goal is to create a website that resembles a game menu, similar to Deus Ex The Fall. I'm u ...

The conditional setState function updates the state value one step later than expected

I have been working on a slider component where the scroll value changes when the user clicks on the left or right arrow by a specified scrollWidth. However, I encountered an issue with this current implementation: const Slider = (props) => { const [ ...

If the <option> "anyTableName" </option> is chosen, then display the column names of the selected table (PHP, MySQL)

Hey there, I'm a newbie on stackoverflow so feel free to correct me if I'm off base ;) Here's my current dilemma: I have a text.php file that contains 2 <select> elements. The first one allows me to choose a table (like "accounts", "c ...

Looking to retrieve selections when the inputValue changes in react-select?

I'm working with a react-select component and I would like to implement a feature where an API request is triggered as soon as the user starts typing in the react-select field. This request should fetch items related to the keyword entered by the user ...

The $digest function in Angular's $rootScope

While engrossed in the incredible book, Mastering Web Development in AngularJS, I stumbled upon this code snippet: var Restaurant = function ($q, $rootScope) { var currentOrder; this.takeOrder = function (orderedItems) { currentOrder = { deferred ...

I want to learn how to display the rupee symbol instead of the default dollar symbol in AngularJS for specific currency symbols

When using 'currency' in AngularJS, I noticed that a dollar symbol is displayed. How can I change this to show the required currency symbol based on different requirements? Currently, I am looking for information on how to display a rupee symbol ...

Where can I find the @types for a specific lodash package?

Seeking to utilize a specific function from lodash - assignin. I have successfully installed lodash.assignin and incorporated it into my project: import assignIn = require('lodash.assignin'); However, when compiling, an error occurs: "error TS2 ...

Using Django to send AJAX POST requests to pass JavaScript variables for form initialization

Currently, I am engaged in a Django project where I have managed to gather all my variables in JavaScript and now attempting to initialize a form (within a modal popup) on the same page without any need for refresh. The form is successfully displaying insi ...

Tips for sending parameters to a web service URL through a Phonegap HTML page

In my Phone Gap application, I have an HTML page where I need to pass the values like name, contact, etc. to a Webservice URL. However, I am unsure of where to write the code and how to call the webservice URL. Here is a snippet of my HTML code: <div ...

Move divs on top of each other while scrolling through a webpage

I am working on an HTML-page that contains multiple DIVs and a function called 'fullscreenCSS' that ensures the DIVs take up the entire screen. My goal is to create a scrolling effect where as I scroll using the scrollbar, the current DIV remain ...

Unable to achieve proper centering and bottom vertical alignment for div element using CSS and HTML codes

I am facing an issue with centering and vertically aligning a div inside another div. Despite setting the CSS properties, it doesn't seem to work properly. Can you please review my code below: #outer { border: 1px solid black; height: 500px; } #in ...

ERROR: JSON - Cannot access property of undefined

My goal is to extract JSON values and create variables from them, but I keep encountering an error. Even when the JSON array is filled, I still face issues. var tempArray = []; $("#sth td").each(function(){ $this = $(this); tempArray.push({"COLO ...

Utilize FileHandle throughout various versions of Node.js

Is it possible to import the FileHandle module successfully across different versions of Node.js? For example, in Node.js v14 and v16, the following code functions properly: import { FileHandle } from "fs/promises"; However, in Node.js v12, thi ...

Error: Attempting to access the 'getCroppedCanvas' property of an undefined value in VueJs

I've been exploring the vue-cropperjs library, but every time I execute the code, I encounter error messages: Uncaught TypeError: Cannot read property 'getCroppedCanvas' of undefined Uncaught TypeError: Cannot read property 'replace&ap ...