Gradually make each paragraph tag appear

If hypothetically I possess numerous p tags:

<p>Style never met and those among great. At no or september sportsmen he perfectly happiness attending. Depending listening delivered off new she procuring satisfied sex existence. Person plenty answer to exeter it if. Law use assistance especially resolution cultivated did out sentiments unsatiable. Way necessary had intention happiness but september delighted his curiosity. Furniture furnished or on strangers neglected remainder engrossed.</p>

<p>Not far stuff she think the jokes. Going as by do known noise he wrote round leave. Warmly put branch people narrow see. Winding its waiting yet parlors married own feeling. Marry fruit do spite jokes an times. Whether at it unknown warrant herself winding if. Him same none name sake had post love. An busy feel form hand am up help. Parties it brother amongst an fortune of. Twenty behind wicket why age now itself ten.</p>

<p>For though result and talent add are parish valley. Songs in oh other avoid it hours woman style. In myself family as if be agreed. Gay collected son him knowledge delivered put. Added would end ask sight and asked saw dried house. Property expenses yourself occasion endeavor two may judgment she. Me of soon rank be most head time tore. Colonel or passage to ability.</p>

that have opacity:0 and my objective is to smoothly fade them in, one after another, with a delay of approximately 350ms.

What method should I employ to achieve this?

All my prior endeavors

$.each($('p'), function(index,element){
    setTimeout(function(){ $(element).fadeIn(); }, 350);
});

were unsuccessful in synchronizing the fading effects for each individual p tag.

Answer №1

Here's a solution:

$("p").each(function(i) {
    $(this).delay(350*i).fadeOut(300);
});

Answer №2

Check out this example:

$("div").each(function(i) {
   $(this).delay(400*i).fadeOut();
});

Answer №3

The simultaneous action of all is due to the synchronization of timeouts set at nearly the same time, ensuring each will wait 350 seconds from initiation.

Give this a shot

ps = $('p').toArray();

function fadeNext(ps){
   $(ps[0]).fadeIn(350, function(){
      ps.shift();
      if(ps.length){
         fadeNext(ps);
      }
   })
}

Check out this code snippet for fading out:

function fadeNext(ps) {
  console.log($(ps[0]))
  $(ps[0]).fadeOut(350, function() {
    ps.shift();
    if (ps.length) {
      fadeNext(ps);
    }
  })
}

$('#fade_button').click(function() {
  ps = $('p').toArray();
  fadeNext(ps);
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p>Style never met and those among great. At no or september sportsmen he perfectly happiness attending. Depending listening delivered off new she procuring satisfied sex existence. Person plenty answer to exeter it if. Law use assistance especially resolution
  cultivated did out sentiments unsatiable. Way necessary had intention happiness but september delighted his curiosity. Furniture furnished or on strangers neglected remainder engrossed.</p>

<p>Not far stuff she think the jokes. Going as by do known noise he wrote round leave. Warmly put branch people narrow see. Winding its waiting yet parlors married own feeling. Marry fruit do spite jokes an times. Whether at it unknown warrant herself winding
  if. Him same none name sake had post love. An busy feel form hand am up help. Parties it brother amongst an fortune of. Twenty behind wicket why age now itself ten.</p>

<p>For though result and talent add are parish valley. Songs in oh other avoid it hours woman style. In myself family as if be agreed. Gay collected son him knowledge delivered put. Added would end ask sight and asked saw dried house. Property expenses yourself
  occasion endeavor two may judgment she. Me of soon rank be most head time tore. Colonel or passage to ability.</p>

<button id="fade_button">try it</button>

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

Vuetify input with appended button showing loader malfunction

One of the fields in my form is an email input with complex validation rules. I'm using Vuelidate for form validation, and once the user enters a valid email, I want to display a 'Check' button to verify if the user exists. While the server ...

selecting the table data (td) within a table using jquery

I am looking to create an event that triggers when a td element inside an HTML table is clicked. Initially, I tried the following code: $('td').live('click', function() { alert($(this).attr('id')); }); T ...

Delegating events after removing a class

I have a button element with the 'next' data attribute <button data-button='next' class="disabled">next</button> When I remove the disabled class to activate it, the click event doesn't trigger as expected $("[dat ...

Having trouble finding elements with Selenium's Multiple Selectors

Attempting to interact with a button that Selenium/Nightwatch.js is unable to locate. The button is not nested within a different iframe. I have tested multiple selectors, but none of them are effective. The elements are visible and can be manually clicke ...

load a particular section of another website into my own div

Similar Question: Ways to bypass the same-origin policy I've been looking for a way to load a specific div from another website using this code. Can anyone provide an example of how to do this on jsfiddle? $.ajax({ url: 'http://somethin ...

Having Trouble Accessing HTML Website on Internet Explorer 11

I'm having an issue with this website: It loads perfectly on Google Chrome, Safari, Firefox, and Edge, but seems to be having trouble with Internet Explorer (IE) 11. Can anyone help me diagnose the problem? ...

Rearrange the positions on the circle

I created a setup where I've arranged multiple items around a camera in a circular manner, and currently they are positioned in a counter-clockwise direction using the following code: answer.position.y = Math.sin(answerBoxRadians) * circleRadius; an ...

Discovering instances of a specific string within a larger string

My goal is to customize the default behavior of the alert function. Below is the code I am using: window.alert=function(txt) { waitOk='wait'; setMsgBox(txt); btnMsgOk.focus(); } However, I need this functionality to vary ba ...

Integrating jQuery into the functions.php file of a Wordpress

I have been using a jQuery script in Unbounce and now I want to implement it on my Wordpress page. I believe I will have to insert this into the child theme functions file, but I know it requires some PHP code as well. As I am still fairly new to this proc ...

NativeScript element isn't showing up

Being relatively new to application development with NativeScript, I find myself in a situation where I need assistance in finding a solution. Drawing from my experience with PHP, I am now looking to create a template for each "page" of the application. Th ...

Vue.js - Including new information in an array and passing it to the props (assistance needed)

I am facing an issue where I want my component to be able to add a new sidebar menu item every time the user clicks an add button. Essentially, my component should appear when the user is defining their own sidebar menu items. Here is the Vue.js code that ...

What is the purpose of including an empty tag option after fetching data from ajax?

My issue involves two dropdown lists, one for category and the other for subs. I want the second dropdown to reload from the server when the user changes the selection in the first dropdown: <select id="cats"> @foreach($all_cat as $c) <option ...

Exploring the functionality of the Aria role attribute within Angular 2

It's strange that the ARIA role attribute doesn't seem to be functioning as expected for me in Angular 2. I attempted to assign a div role of "listbox" and set the children as role "option", but it still doesn't work. Could someone assist m ...

How to enable the Copy to Clipboard feature for multiple buttons and transition from using an ID to a class identifier

Can someone please assist me? I have a copy to clipboard function that works well for IDs and a single button on my website. However, I need to modify it to work for multiple buttons and values with a class identifier. Unfortunately, I am unsure how to mak ...

improving the blend of flow and union types

Check out the code snippet provided below. To prevent any flow errors, I had to perform two casts as using the commented lines resulted in complaints. playground /* @flow */ import * as React from "react"; type ConfObj = { label: string }; type Conf = ...

Tips for replacing http://locallhost with ~/ in an HTML string

Is there a way to replace every occurrence of "http://localhost:59455/" before "Images/TestFiles/(file name)" in the C# code snippet below? string tags = @"<p><img class='img - fluid' src='http://localhost:59455/Images/TestFiles/1. ...

Guide: Looping through a typed Viewbag array - best practices

I have passed a List<AdminUsers> through the Viewbag to a view. This list is then assigned to a JavaScript variable and looped through. However, when debugging on the view, I noticed that the for loop is not being executed, even though I set a break ...

jQuery for Implementing Pagination Across Multiple Tables

As a novice in the world of JavaScript and jQuery, I am struggling with implementing pagination for multiple tables on a single page. My goal is to have several tables that can be paginated using one navigation system. However, all my attempts so far have ...

Is there a specific method for organizing cached buffer conversions in Node.js for optimal efficiency?

In a GitHub discussion, it was pointed out that the Map's .has method does not work with buffers because identical buffers are considered as distinct objects. This limitation became apparent when attempting to store buffer string conversions in a map ...

Issue encountered while fetching data from SQL database in a Node.js application

After successfully connecting the database to my node js project, I encountered an issue when attempting to retrieve data using the get operation. Despite the connection working fine, I was unable to resolve the error that occurred. Establishing the SQL c ...