Stopping jQuery fadeOut from setting the display property to 'hidden'

I am currently working on a project that involves creating a lightbox effect. I am using jQuery's fadeIn and fadeOut functions to display enlarged div elements. However, I have encountered an issue - when I use fadeOut on the enlarged div, the smaller one also disappears because fadeOut sets display: none upon completion. Is there a way to apply fadeIn and fadeOut to a copy of a div without affecting the original? It is important to note that this particular div does not contain an image but rather a large set of other divs and text.

Here's the snippet of my current jQuery code:

$("#magnify").on("click", function(event){
    $("#black-overlay").addClass("show");
    $(".close").addClass("show");
    $("#inner-box").addClass("enlarge").fadeIn(600);
});

$(".close").on("click", function(event){
    $("#inner-box").fadeOut(600);
});

The complete HTML structure is quite lengthy, so here's a simplified version. Essentially, I want everything within the inner-box to enlarge as well as fade in and out when specific elements are clicked:

<div id="outter-box" class="activeSlide">
    <div id="magnify"><a href="#"><p>Enlarge</p></a></div>

    <div id="inner-box">    
        <div class="close">
            <a href="#"><img src="img/close.gif" width="22px" height="22px" /></a>
        </div>
        <div id="content">
            <div class="inside">
                <p>A lot of content here</p>
            </div>
        </div>
    </div>
</div>

Answer №1

Here is a suggestion you can consider:

.fadeOut({opacity: 0}, 400);

If browser prefixes are needed, you could try the following for specific browsers:

.fadeOut({MozOpacity: 0}, 400); // Firefox
.fadeOut({WebkitOpacity: 0}, 400); // Chrome, Safari
.fadeOut({OOpacity: 0}, 400); // Opera
.fadeOut({msOpacity: 0}, 400); // Internet Explorer

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

Achieve a full-width background video without adjusting the height, preferably without the use of JavaScript

I have scoured various sources in search of the answer to this question but have come up empty-handed. While I am aware that similar queries have been made before, please hear me out. I am interested in incorporating a video background on a website where ...

What are the solutions for resolving problems with the display and functionality of a multi-page form in Internet Explorer?

I am currently working on a form and you can view it at this link: http://jsfiddle.net/pPWr3/14/ While the form displays correctly in Chrome and Firefox, I am experiencing display and functionality issues when using Internet Explorer 9. The problems inclu ...

What is causing the floated element to overlap the element below instead of vice versa?

div { background-color: #00FFFF; } p { width: 50px; height: 50px; border: 1px solid black; margin: 0px; } #p1 { background-color: red; float: left; } #p2 { background-color: green; } #p3 { background-color: orange; } #p4 { backgr ...

Something is amiss with the PHP email validation functionality

I have been facing issues with the functionality of my form that uses radio buttons to display textboxes. I implemented a PHP script for email validation and redirection upon completion, but it doesn't seem to be functioning correctly. The error messa ...

Issue with change event not firing upon page load

In my production record creation page, I have implemented functionality to handle different line, shift, and date combinations. There are drop down menus for selecting the line and shift, as well as a jQuery date picker for selecting the date. One issue I ...

What is the best way to include JSON values for specific keys using JavaScript, jQuery, or AngularJS?

Below is a sample of the json: var json = var data = [{ "a": 150 }, { "a": 50 }, { "b": 100 }, { "b": 25 }]; I aim to combine the values of "a" and "b" in a new finaljson(the desired output json), like so: var finaljson = [{ "a": 200 ...

Creating a dynamic JQuery navigation menu directly from a MySQL database table

I am looking to dynamically populate the menu on this website (http://www.hv-designs.co.uk/tutorials/sliding_menu/sliding_menu.html) with values from a MySQL table. Essentially, when the user clicks on the top menu button, I want the menu items to be rows ...

Generating a PDF from a CSS3 multi-column layout with the help of snappy (a wrapper for wkhtmltopdf)

I am attempting to create a PDF with three columns using barryvdh/laravel-snappy and wkhtmltopdf. Since the text that will populate these columns varies in length, I need a method that allows the text to flow freely within the columns. I have attempted to ...

Looking for assistance with transferring a JavaScript array to my PHP script

Is there an easier way to transfer a JavaScript array to a PHP file? I've seen examples of using AJAX for this task, but I'm wondering if there's a simpler method. Below is a snippet of the code I'm working with: <html> <hea ...

How can I design a trapezoid with see-through borders and background?

Using various CSS border tricks, it's possible to create a trapezoid shape. Additionally, setting the border-color to rgba(r,g,b,a) can make it transparent. However, is there a way to create a trapezoid with both transparent borders and background? ...

Vue.js compatibility issue with SelectBoxIt jq plugin causing malfunction

On a page with numerous dynamically generated select boxes, I am looking to incorporate the jQuery selectBoxIt plugin from . Using Vue js, where is the best placement for the following code snippet to connect the plugin with the select elements? $('. ...

Refresh the table every couple of seconds

I need to regularly update a table every two to three seconds or in real-time if possible. The current method I tried caused the table to flash constantly, making it difficult to read and straining on the eyes. Would jQuery and Ajax solve this issue? How c ...

Challenge with Alignment of Fields in Bootstrap's Horizontal Form

I am working on an Angular project with a horizontal form using Bootstrap. I have encountered a slight alignment issue with one of the date fields. The IsMessedUp datepicker input field is not aligned properly, positioned slightly to the left compared to t ...

Ways to prevent styles from being overridden by those specified in JavaScript

Some elements on my page have their style dynamically changed by JavaScript. However, I want one of them to maintain its static style without being overridden. Is there a way to specify that the style of this particular element should not be altered? Than ...

Tips for developing a sophisticated HTML quiz

I have spent countless hours perfecting this quiz. I have successfully created a quiz that reveals solutions at the end, but I want to take it one step further. I envision the answers appearing after each incorrect response from the user, and no answer sho ...

Using Rails AJAX to dynamically load partials without the need to submit

Imagine creating a dynamic page layout with two interactive columns: | Design Your Pizza Form | Suggested Pizzas | As you customize your pizza using the form in the left column, the right column will start suggesting various types of pizzas based on your ...

Searching for all classes and IDs in a CSS Stylesheet that include a specific keyword

I am currently working with a premium WordPress theme that has an extensive styles.css file consisting of over 25,000 lines. My goal is to make sitewide changes to the font and main color, and in order to do this effectively, I need to identify all classes ...

Using the textbox input to trigger an alert message

Just starting out with JavaScript and I'm attempting to create an alert box that not only displays the message "Thank You For Visiting" when you click the Enter button, but also includes the name entered into the text box. While I have successfully im ...

Using jQuery to send JSON data through AJAX to PHP

I'm attempting to utilize jQuery AJAX to send JSON data to a PHP file. My goal is to extract the values and IDs from multiple child elements, create a JSON object with this data, and then transmit that object to a PHP file for processing and insertion ...

Preventing special characters in an input field using Angular

I am trying to ensure that an input field is not left blank and does not include any special characters. My current validation method looks like this: if (value === '' || !value.trim()) { this.invalidNameFeedback = 'This field cannot ...