Fade in and out of page or div elements with a simple click

I've been dedicating some time to my recruitment website lately. As a beginner in coding, I'm looking for a script that will automatically fade out the Employment review content when clicking on each employment vacancy div and then fade back in when clicking "close" on the Employment review page. Any suggestions would be greatly appreciated. Thank you.

Answer №1

If you want to achieve a fade effect, you can utilize jquery in the following manner: http://api.jquery.com/fadeout/

$( "#vacancy-div-id" ).click(function() {
  $( "#id-of-what-you-want-to-fade-out" ).fadeOut( "slow", function() {
    // Animation complete.
  });
});

To initiate a fade in effect, you can use this method: http://api.jquery.com/fadein/

$( "#close-button-id" ).click(function() {
  $( "#id-of-what-you-want-to-fade-in" ).fadeIn( "slow", function() {
    // Animation complete
  });
});

For a more detailed example - Add this code snippet to your html file:

<script>
    $( "#close-button-id" ).click(function() {
      $( "#id-of-what-you-want-to-fade-in" ).fadeIn( "slow", function() {
        // Animation complete
      });
    });
</script>

If you are unsure of the id required to trigger the fadeIn animation, you can right-click on the element and select inspect to view the html structure of your page.

Answer №2

    #beginning{
        height:120px;
        width:320px;
        border:4px solid blue;
        display: none;

    }
    #beginning.fadeIn{
        display: block;
        animation-name:appear;
        animation-duration:3s;
    }
@keyframes appear {
    from {
        opacity:0;
    }
    to {
        opacity:1;
    }
}

document.getElementById('execute').addEventListener('click',function(){
        document.getElementById('beginning').classList.toggle('fadeIn');
    })


<div id="beginning" class="spinning">
            some different text  some different text  some different text  some different text  some different text
    </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

Identifying with a jQuery IF statement all input fields that contain null values in order to eliminate the respective elements

My goal is to create a jQuery script that checks all input fields to see if they are empty. If an input field is empty, I want to remove the child image of the next occurring span element. Here is what I have attempted so far: if ($("input").val() == "") ...

Reloading fnDrawCallback or fnInitComplete in JQuery DataTables using fnReloadAjax() - A complete guide

I am facing a dilemma with my dataTable of users, where I am allowing admins to edit the information. The issue arises when trying to bind jquery functions to specific cells in the datatables. The usual practice is to list the functions in either the fnD ...

Display issue with grid-template-column not appearing

My grid column isn't working in my Christmas matching game project. I'm trying to create additional card columns using grid template columns, but the other three columns are not displaying as intended. They should be positioned right next to "Tim ...

What is causing the failure in retrieving the smallest number from this array?

The maximum value should be 9.99, and the minimum value should be 6.88 let arr = [["2019","00","01", 9.99], ["2018","00","01", 9.32], ["2017","00","01", 6.88]] let max = Math.max(Number(...arr.map((o) => { return o[3] }))); //9.99 let min = Math.mi ...

Learn how to dynamically clear and update source data in jQuery autocomplete for enhanced functionality

Here is a snippet of my jQuery code. In this code, 'year' refers to the form input tag ID, and 'years' is an array variable containing all the year values. I have set this array as the source for autocomplete, which works fine. However, ...

Issues arise in the alignment of the tab order when utilizing a combination of the stripe card

Experiencing an issue with tab index not working properly when using Vue.js and having a stripe card-element inside the Vue main element. Below is the code snippet: <html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js ...

What is the best way to eliminate duplicate values within a v-for array?

To eliminate duplicate values, I wrote the following code: vue <div class="col-md-6" style="float: left"> <ul class="list-group"> <li class="list-group-item" :class="{ active: ind ...

"Leaflet automatically refreshes tile cache when zooming in or out

Currently, I'm facing an issue regarding the tile cache in leaflet. If I move from point A to point B, and examine the tiles in between, they are cached without any problems. However, if I go from A to B, zoom in and out, and then return to point A, ...

Why is my main.scss having trouble importing other files?

I am experiencing issues with importing my scss file. First, I created a file called main.scss and added some code to it. All the codes are functioning properly and showing up on the webpage. Next, I created two folders named settings and elements. In ...

Issues encountered with jQuery Form Plugin failing to pass a string value to PHP

I'm currently experimenting with the jQuery form plugin (http://jquery.malsup.com/form) to handle photo uploads and previews. However, I'm encountering an issue where the data strings expected to be sent to PHP using the ajaxForm function are com ...

The functionality of Ajax is not functioning as expected in the view of the

I can't figure out why my code isn't working. I'm simply trying to make a request to one of my controllers and receive a JSON result in response. The script in my view appears as follows: <script src="http://ajax.googleapis.com/aja ...

Struggling to make the bootstrap navigation bar function properly

I've been experimenting with replicating the basic framework to learn more about responsive web design using bootstrap. However, I've only been able to get certain parts to function correctly. For instance, I can use the "btn" class without any i ...

Unable to get ng-submit function to work properly within the Laravel PHP framework

Hello everyone, I have an inquiry regarding Laravel/AngularJS. In my project, there is a form where users can post questions. However, when I click the submit button, no requests are sent (as per inspection in Google Chrome). Interestingly, the Log in int ...

Ways to display tinyMCE content in a unique manner

I've been diving into node.js/express/mongoDB and decided to create a blog. I encountered an issue with rendering the content inputted through tinyMCE as HTML - instead, it's displaying the tags around my content. How can I properly display it as ...

What could be causing the "Error - Only secure origins are permitted" message to appear for my service worker?

Whenever I attempt to implement a service worker on my progressive web application page, why does the browser console display this specific error message? ERROR "Uncaught (in promise) DOMException: Only secure origins are allowed JavaScript Code: ...

Utilize grids to ensure consistency in the width of every <li> element across the browser

Is there a way to make the ul element span the entire width of the webpage regardless of window size? http://jsfiddle.net/32hp1w5p/ ul { grid-column: 1/13; list-style-type: none; display: table; margin: 0 auto; } li { float: left; border: ...

Is there a way to assign retrieved data to the $scope.variable?

I'm relatively new to both JavaScript and Angular. I have a piece of code that fetches data from an API and successfully prints it to the console, but I'm facing issues when trying to assign this data to $scope.saveData. It seems to only work wit ...

Calculate the percentage variance across two figures (multiple occurrences)

My goal is to execute the result function for each instance of item. The desired output of the result function is the percentage calculated by dividing value / max. However, I am facing issues when using value and max as variables in the function. $(".l ...

The JSON data may be improperly formatted

My script is not functioning correctly, it returns about 20 undefined values before finally displaying the full_name: function retrieveUserInfo(phrase) { $.ajax({ url: 'get_staff_details.aspx?rand=' + Math.random(), type: &ap ...

Ways to confirm the existence of a specific attribute within a selection

In this HTML select element: <select id="select-filter-item" data-hasqtip="true" title="" aria-describedby="qtip-3"> <optgroup label="Servizi" type="services-group"> <option type="provider">Tutti i trattamenti</o ...