Foundation 4 - image hover effect to display alternate image

I am a newcomer to Foundation 4, but I have some coding experience. Currently, I am in the process of transitioning my photography blog (www.momentaryawe.com/blog) from Wordpress with a custom theme to a custom theme built on Foundation 4.

Most aspects of the transition have gone smoothly, however, I have hit a roadblock. If you visit this link () you will see that currently when someone hovers over an image, another image is displayed which is the original shot from the camera. Both images are uploaded when the post is created. This hover effect is achieved through the following jQuery code:

$(function() { 
  $("#rolloverOriginal ul li").hover(
    function() { 
        $(this).find('p').fadeIn(); 
    },
    function() { 
        $(this).find('p').fadeOut();
    }
);
});

My issue arises because Foundation 4 uses Zepto which does not support the hover option. I am unsure of how to replicate this effect using Foundation 4. I considered using Orbit for this, but so far I have been unable to get it to work on hover.

Answer №1

If you prefer, you can choose to skip using zepto and go with jQuery instead. To implement this change in your code, simply adjust it to include the jQuery file or opt for a CDN:

<!-- Check for Zepto support, load jQuery if necessary -->
<script>
  document.write('<script src=/js/vendor/'
    + ('__proto__' in {} ? 'zepto' : 'jquery')
    + '.js><\/script>');
</script>

This adjustment results in:

<!-- Check for Zepto support, load jQuery if necessary -->
<script>
  document.write('<script src=/js/vendor/jquery.js><\/script>');
</script>

Alternatively, you can use a CDN version:

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

In my experience, due to browser compatibility issues with zepto, I find jquery to be a more reliable choice.

Update: I have incorporated jquery v1.10.1 into the code, but note that hover is not supported. In such cases, you can replace it with mouseenter and mouseleave. Here's an example:

$(function() { 
  $("#rolloverOriginal ul li")
    .on('mouseenter', function() { 
        $(this).find('p').fadeIn(); 
    })
    .on('mouseleave', function() { 
        $(this).find('p').fadeOut();
    });
});

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 font size of the textarea dynamically adjusts based on the size of the screen

Some strange behavior is occurring in the Android default browser when I set the width and height of a textarea to 100%. The font size of the textarea seems to increase based on the screen size, and even though I attempted to alert the font-size using jQue ...

Issue with MaterialUI value prop not updating after dynamic rendering of components when value state changes

As I dynamically generate Material UI form components, I encounter an issue with updating their values. The value prop is assigned to a useState values object, and when I update this object and the state, the value in the object changes correctly but the M ...

Optimizing communication of time data in Laravel and Vue.js using Inertia

Currently, I am encountering an issue while working with Laravel Inertia and Vue.js. The problem arises when the time is transferred between Laravel and Vue.js, as it always converts to UTC automatically, which is not what I want. For instance, if I am u ...

The conversion of a 2D json array into a string is mistakenly performed

On hand is an outer array that contains 2 arrays within it, making it a 2-dimensional array. This is how the array is initialized: $outerArray = array(); $nestedArray = array("first", "second", "third", "fourth"); $outerArray[] = $nestedArray; $nest ...

`Failure to prompt an error following an unsuccessful post request in a node.js application using axios and express`

I'm currently facing an issue while trying to implement password change validation. The problem lies in not receiving the errorMessage from the server in case of an error. Although I've successfully managed to update the password and send back a ...

Guide on accessing and displaying data table values in console.log using Vue.js and vuetify

Hello, I am new to Vue.js and I am trying to work with data tables. I have copied some code from the Vuetify website and I am attempting to call the desserts' names from a sample table using console.log. Below is the code snippet: <template> ...

Managing project versions and branches with gulp as the source control system

As a beginner in node.js and gulp, I apologize for the simplicity of my question. I am embarking on a new jQuery project using node.js and gulp. Below is the structure of my directory and files: /root-pluign-directory | ---- dist (holds release f ...

Can text be replaced without using a selector?

I am utilizing a JavaScript library to change markdown into HTML code. If I insert <span id="printHello></span> within the markdown content, I can still access it using getElementById() after conversion. However, there is one scenario where th ...

Combining two items from separate arrays

How can I efficiently merge objects that share the same index in two different arrays of objects? Below is the first array const countries = [ { "name": "Sweden", "nativeName": "Sverige" }, ...

Utilizing Multiple Select Options and CSS Float Styling in Mozilla Firefox

I have been attempting to customize the CSS of a multiple select element. While I am satisfied with how it looks on Chrome, I am facing issues getting it to work correctly on Mozilla Firefox. $('option').mousedown(function(e) { ...

Issue with Webpack throwing 'window undefined' persists despite using the 'use client' configuration in React/Next.js

I've been using Typescript 5, React 18, and Next.js 14 as my tech stack, and I keep encountering similar errors with various libraries. One of the errors I often face is ReferenceError: window is not defined. This error originates from a third-party ...

What is the best way to center text within an input field?

I've been attempting to center the text in the span tag within the input field, but using "text-align": center in my css doesn't seem to be working as expected. Interestingly, when I switched the span tag to a paragraph tag, it caused the input ...

What is the proper way to retrieve an object from a json file?

My JSON structure looks like this: { "total": 4367, "page": 1, "per_page": 10, "paging": { "next": "/videos?query=second%20world%20war&per_page=10&access_token=XXX&page=2", "previous": null, "first": "/v ...

The issue of the menu in the <Select /> component unexpectedly closing is caused by the MaterialUI -withStyles higher-order component (HOC)

Issue Description When utilizing the <Select /> component with the multiple attribute, users should be able to select multiple options without the dropdown menu closing. This functionality works as intended when using the <Select /> component ...

Establish a many-to-many relationship in Prisma where one of the fields is sourced from a separate table

I'm currently working with a Prisma schema that includes products, orders, and a many-to-many relationship between them. My goal is to store the product price in the relation table so that I can capture the price of the product at the time of sale, re ...

The argument type does not match the parameter type partial<>

While attempting to validate my Ionic React form, I encountered an error when calling the validationSchema within the useForm method. The specific error message received is as follows: Argument of type '{ validationSchema: ......' is not assignab ...

What causes the behavior of <body> backgrounds to differ from that of other HTML elements?

After examining the HTML code provided: <p style="margin:100px;border:1px solid red;background-color:#dff"> Hello </p> We can observe that when rendered by the browser, it looks like this: If we were to modify the document as follows: < ...

There seems to be an issue with the functionality of Array.filter when trying to use it with arrays

I am facing an issue with filtering branchId from an Array. Here is the code snippet and steps I have taken. const [branchID,setBranchID]=React.useState([]); const tempTwo=[ { branchId: "61b25e0ae177d62ce4cb3b47", bra ...

Is it possible for us to perform an addition operation on two or more items that belong to the same

I am faced with a challenge involving 3 objects of the same type, each having different values for their properties. My goal is to add them together as illustrated below: Consider this scenario: objA = { data: { SH: { propertyA: 0, propertyB: ...

Stopping navigation in Vue router

<router-link to="SOME_ROUTE"> <div class="outer-div"> <div class="inner-div" v-on:click="doSomething"></div> </div> </router-link> I am currently working on creating a link with an image included. My goa ...