Issues with JQuery in the Footer

Trying to achieve a footer that expands when moused-over using the following HTML/jQuery code below. However, the footer remains static and does not expand at all (see CSS at bottom).

HTML:

<div id="footer">
    <div id="v_line"></div>
    <div class="column">
        <ul id="lpro">  <a href="https://www.google.com/" target="_blank"><div class="googleme">  
                <img src="google.png" alt="google_filler"></div></a>

        </ul>
    </div>
    <div class="column">
        <ul id="spro">  <a href="https://www.yahoo.com" target="_blank"><div class="yahoo"><img   
                 src="yahoo.png" alt="yahoo_filler"></div></a>

        </ul>
    </div>
</div>

JavaScript (with JQuery):

function openmenu(e) {
    if (e) e.stopPropagation();
    $('#footer').animate({
        height: "75px"
    }, 400, null, function () {
        $("#footer").off("mouseenter");
        $('#footer').on('mouseleave', closemenu);
    });
}

function closemenu(e) {
    if (e) e.stopPropagation();
    $('#footer').animate({
        height: "33px"
    }, e ? 400 : 0, null, function () {
        $("#footer").off("mouseleave");
        $('#footer').on('mouseenter', openmenu);
    });
}

$(function () {
    $('#footer').on('mouseenter', openmenu);
    closemenu();
    $("body").css("overflow", "hidden");
});

Footer CSS:

#footer {
    position:absolute;
    bottom:0px;
    left:0px;
    right:0px;
    background-color:#0F0F0F;
    height:150px;
    opacity:0.8;
}

Answer №1

No need for Javascript in this case. Try using CSS instead:

#footer{
  position:absolute;
  bottom:0px;
  left:0px;
  right:0px;
  background-color:#0F0F0F;
  height:33px;
  opacity:0.8;
  transition: height 400ms;
}

#footer:hover {
  height: 150px;
}

To enhance performance, consider using an animation with translate like this:

#footer{
  position:absolute;
  bottom:0px;
  left:0px;
  right:0px;
  background-color:#0F0F0F;
  height:150px;
  opacity:0.8;
  transform: translateY(120px);
  transition: transform 400ms;
}

#footer:hover {
  transform: translateY(0px);
}

Answer №2

I successfully tested the script myself. The only modification I made (compared to your original version) was updating the jquery link.

If the website is live, consider making the following change:

<script src="jquery.js"> </script>

Change it to:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

This ensures that you are loading the most up-to-date version of jQuery.

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

Display images quickly when the mouse is hovering

I am looking to create a function that will flash images when the mouse hovers over them and then stop flashing when the mouse moves away. However, I am experiencing an issue where "flash_imgs" is being called every time there is a mouse movement over the ...

Displaying a jQuery UI tooltip when selecting an option

Is there a way to use JQueryUI to display tooltips for individual options within an optionset or dropdown, rather than just the default tooltip? I've attempted to create a Sample I'm not looking for the selected option to show its title like in ...

CSS properties for SVG image borders not displaying correctly

I'm having trouble creating a border around a round SVG image with the class "lock feature". When I try to add the border in the CSS element ".lock feature", the text "feature" stays white and the border doesn't show up in the browser. However, i ...

Modifying the TITLE dynamically post header insertion: A guide

Is there a way to dynamically change the title of an HTML page based on the content included below the header section using PHP? For example: <html> <header><title>I would like to change</title></header> <!--CONTENT--> ...

Tips for transferring date values in an ajax request to a web application handler

I am currently working on plotting a graph between two dates using Google Charts. My goal is to send date values to the controller, which is implemented with webapp2. However, I am facing difficulties in figuring out how to send date values to the controll ...

The hover effect on <a href element will only activate after clicking or refreshing the page

Having an issue with my website where I'm using HTML and CSS exclusively. The problem arises when I have multiple "a hrefs" that should change their background colors slightly when hovered over. However, whenever I clear the browser cache or go into i ...

Angular's directives do not trigger the 'viewContentLoaded' event

I recently created a 'light-gallery' directive that relies on the jquery.lightgallery.js plugin to initialize the $.fn.lightGallery() functions. It is crucial for these functions to be executed after the directive template has been compiled and l ...

Bootstrap breakpoint activated on mobile window

Is there a way I could insert a breakpoint for when the HTML content is displayed in a small window, like xs? <br class="show-when-small-window"> ...

How can I create a hover effect for multiple divs sharing the same id using CSS or JavaScript in the easiest way possible?

When hovering, I want the opacity to be set at "0.3"; when not hovering, it should be set at "1". Additionally, the color of h2 and h3 in each div should transition from white to red. I have searched extensively online and tried to sol ...

How can I save a value in JavaScript once the page has finished loading?

$("#divid1").click(function(){ $("#divid1").hide(); //this should remain hidden even after refreshing the page $("#hideid1").hide(); //this should remain hidden even after refreshing the page $("#id1").show(); //this should remain visible even ...

Is it feasible to completely erase the coding history of a website that has been indexed

Is it possible to completely erase the code-history of a website once it has been indexed by Google and other search engines? I have some content on a website that I want to remove from history, but I'm not sure if it's possible due to factors li ...

Maintain the same UI appearance when the checkbox state is altered

<input type="checkbox" [(ngModel)]="rowData.is_permitted" (change)="changeStatus()"> changeStatus() { rowData.is_permitted = true; } When I uncheck the checkbox but conditionally want to select it again, the flag is updated but does not affect the ...

Choose every fourth row in the table

Is there a way to alternate the background colors of selected groups of 4 rows in a table? I want to make one group red and the next group blue. Any suggestions or ideas on how to achieve this? <table> <tr style="background-color: red;"> ...

What sets apart the <script> tag with a type attribute from the standard <script> tag in HTML?

Similar Question: Is it necessary to include type=“text/javascript” in SCRIPT tags? While working on my HTML project, I noticed that the JavaScript code within script tags is evaluated even if the type attribute is not explicitly set to "j ...

Can BeautifulSoup be utilized to retrieve CSS from a webpage?

Currently, I am tackling a project that necessitates the full view of a webpage instead of just scattered lines entwined with images in HTML format. Is there a method to parse CSS alongside HTML using BeautifulSoup? Below is an excerpt from my code: from ...

Utilizing jQuery for manipulating href attributes

Having some trouble with a jQuery selector to click on a link. Any suggestions or solutions? Thanks in advance. $tweet.html(tweet.created_at + ' <a href="#" class="'+tweet.user+'">@' + tweet.user + '</a>: ' + twee ...

changing the core JavaScript of a keyboard plugin

To access the demo, click on this link: . You can find the main javascript file at https://raw.githubusercontent.com/Mottie/Keyboard/master/js/jquery.keyboard.js. Is there a way to switch the positions of the accept and cancel buttons? ...

No data returned from Ajax request

I am using jQuery serialize and Ajax to capture form values and process them with JSON as the data type, but I am not getting any values returned. I have tried different approaches to troubleshoot this issue, but so far I haven't been successful. Ther ...

Can someone explain the process of using grep to search between two specific strings

I have extracted some data: <span class="html-tag">&lt;script&gt;</span></td></tr><tr><td class="line-number" value="1431"></td><td class="line-content"> var awbManifests = {"requestId": ...

Deck.gl's StaticMap component from Mapbox fails to resize properly, causing it to overwrite other elements on the screen

I am encountering an issue while trying to integrate a basic deck.gl (mapbox static map) into a react project. Although I can successfully add the map, it ends up taking over the entire page and hides any other content that should be visible above it. Spec ...