Experience the captivating effect of jQuery's fade in animation as one image gracefully

I have an 800x500 image where the bottom two quadrants feature edits to the graphics that I want to fade in gradually.

If we divide the whole image into AB CD

Sections C & D are what will be covered up after 10 seconds with two images fitting in the bottom quadrants. Initially, I used display:none; assuming that the fadein() function would manage the transition, but it seems like I made a mistake somewhere.

You can view the fiddle here. The particular images may differ, but the sizes remain accurate.

style.css

*{
    margin:0;
    padding:0;
    background-color: #000;
}

#container {
    position: absolute;
    bottom: 0px;
    top: 0px;
    display:inline;             
}

.bottom-left {
    position:absolute;  
    top:250px;
    left: 0px;
    display: none;
}

.bottom-right {
    position:absolute; 
    top:250px;
    left:400px; 
    display: inline;

}

The page:

<!DOCTYPE html>
<html>
<head>

<!-- STYLE SHEETS -->
        <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>

<!-- JQuery * QTip Plugin at the bottom --> 
        <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>


<script type="text/javascript">
    $(document).ready(function(){   
        $('#bottom-left').fadeIn(10000);
    });
</script>

</head>
<body>
<div id="container">

<image src="images/NoAlertFull.png">
        <span class="bottom-right">
                <image src="images/Alert-red.png">
        </span>
        <span class="bottom-left">
                <image src="images/Alert-yellow.png">
        </span>     
</div>

</body>
</html>

Answer №1

Use the class name instead of the id when selecting the span:

$('.bottom-left').fadeIn('slow');

Answer №2

Remember, when selecting elements by class name in CSS, use a dot before the class name.

 $('.bottom-left').fadeIn(1000);

Check out this example here: http://jsfiddle.net/CwgyW/5/

For more information on using jQuery to select elements by class, visit: http://api.jquery.com/class-selector/

If you want to target an element by its ID, remember to use the # symbol.

Ex : $("#myDivId").fadeIn(3000);

When selecting elements by class name, make sure to prefix the class name with a dot.

Ex : $(".myCSSClassName").fadeIn(3000);

Answer №3

Be sure to use the id selector #bottom-left instead of the class selector .bottom-left when styling your elements.

Remember, when working in jsfiddle, you should only paste the body content into the editor as it already has its own document outline.

Check out the demo here: http://jsfiddle.net/examplelink1234/

Answer №4

 $('#bottom-left').fadeIn(10000);

needs to be changed to

 $('.bottom-left').fadeIn(10000);

# is used for selecting by id

. is used for selecting by class

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

Send an array using jQuery's $.post method

I am experiencing an issue with sending an array in $.post to PHP. When I use var_dump, the result is showing as "NULL" and JSON.stringify is not working. JQUERY var photobox = []; photobox.push(e.target.result); $.post("../modules/upload.php",{"imag ...

What is the best way to interrupt an animation and restart it?

On my webpage, I have implemented some anchors and links that navigate to these anchors. When I click on a link, the background-color of the anchor changes. I use animation to gradually fade out this color over 10 seconds - starting with white and then rem ...

Is the CSS after-before property not functioning properly?

In my CSS code, I am utilizing the after and before tags. This is the structure of my div. However, I am facing an issue where my after tag is not functioning as expected. While everything else seems to be working fine, the after and before tags are not di ...

Trouble with Ajax call after transitioning from getJSON to Amcharts

Here is the method for making an AJAX call in a JavaScript file to create a bar graph using Amcharts. The script is located in the bar.js file: plot_graph(); function plot_graph(){ $.ajax({ url:back+"/cool?day=30", type: "GET", dataformat ...

Struggling to determine the exact parameter values needed for the jQuery element scrollLeft and scrollTop functions? Let us lend

Update I recently made a switch from using the javascript scrollLeft and scrollTop functions to the native scrollTo function. This change helped me streamline the scrollbar assignment into a single call, eliminating the need for jQuery overhead. Context ...

The CSS opacity property fails to function properly on Google Chrome

While it is functioning correctly on Firefox, there seems to be an issue with Chrome. I am attempting to have a card apply the opacity property when hovered over. Here is the HTML file: <div class="col mb-4"> <a class="text ...

I am looking to showcase a series of icons linked together by connecting lines

I have successfully designed the layout and added icons, but I am facing difficulty in creating connecting lines between them. I attempted to utilize CSS borders and pseudo-elements, yet I cannot achieve the desired outcome. If anyone could offer a CSS-ba ...

What could be causing the misalignment of the Datepicker calendar in Material UI?

I have integrated a datepicker using the library "@mui/x-date-pickers/DatePicker". import { DatePicker } from "@mui/x-date-pickers/DatePicker"; import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment"; import { Locali ...

Determine selected option in Radio Button

FORM : <form id="approvalPenambahanUserInt" name="approvalPenambahanUserInt" action="" method="post"> <div class="form-group"> <div class="col-sm-12"> <label for= ...

Utilizing jQuery for seamless and ongoing animation effects

I have encountered many questions regarding jquery animation, but so far I haven't come across a solution that works for my specific case. While I have seen numerous examples of using the .animate function with a "complete" parameter callback, none o ...

Problem with incorporating responsive gifs

I'm new to CSS and I'm trying to incorporate an animated GIF as a smartphone screen using Bootstrap to ensure responsiveness. I've managed to get it working for larger and medium screens, but the issue arises when resizing for smaller displa ...

Is it possible to remove the left margin on an li element by placing a td element inside it using HTML and

Here is my custom HTML code including the CSS styles: <!DOCTYPE html> <html> <head> <style> table td { border: 1px solid black; } li { margin-left: 3 ...

After each alert triggers a page refresh, it should not automatically refresh. To prevent the refresh, I implemented a preventDefault function that works seamlessly in Chrome but not

My code is experiencing an issue where event.preventDefault() works in Chrome, but not in Firefox. I have tried both methods and searched for solutions, but nothing seems to be working. If needed, I can post all of my code if the error cannot be found. fu ...

Can we expect every bullet point to be consistently indented at precisely 1.8em?

Recently, I created a dropdown menu using only CSS. The challenge was to have a horizontal bar of items that can each expand into a vertical menu. However, I wanted the expanded menus to display bulleted lists instead of tertiary menus. By nesting three ul ...

Unearthing the worth of the closest button that was clicked

I am currently working on a profile management feature where I need to add students to the teacher's database. To achieve this, I am using jQuery and AJAX. However, I am encountering an issue where clicking the "add" button for each student listed on ...

Ways to eliminate unused classes from JQuery UI

We have successfully implemented JQuery UI library for enhancing our interface. However, since we no longer need to support outdated browsers like IE6, classes such as .ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl are unnecessary and clu ...

What is the best way to replace the empty months in an array with zeros?

I have a dataset with information about customer data for specific months, but some months are missing. The current array looks like this: dashCustomerData = [{ "req_count": 1, "revenue": 11868.19, "getMonth": "August", "count(compID)": 2 ...

The malfunctioning Bootstrap navbar dropdown menu is causing a disruption in user experience by unexpectedly logging the user

I'm having an issue with the dropdown menu on my angular app. Every time I click on the Profile link to access the Account and Logout options, it automatically logs me out. <nav class="navbar navbar-expand-lg bg-dark navbar-fixed-top" ...

Create a new row dynamically each time by emphasizing on the last element of the row

I am having an issue with my table. When I focus on the last row element, I want to copy that row and append it at the end of the table. My current code allows me to do this successfully. However, once the new row becomes the last row, I am unable to gene ...

Is it possible to only show the div element in my AJAX request without displaying the entire page

Is it possible to only show a specific div in my ajax request without displaying the entire page? The entire page is loaded, but I only want to display one div and hide the header and footer. However, I still need the header to be present on the page. jQ ...