Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8290791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:54:52+00:00 2026-06-08T12:54:52+00:00

I want to select specific children elements from the $el.html, there are two types

  • 0

I want to select specific children elements from the $el.html, there are two types of children elements, one with <span>....</span>, the other has a span class <span class = "special">..</span> for example:

var orig = $(".example").html()
    ,$el = $(".example")
    ,text = $.trim($el.text())
    ,words = text.split(" ")
    ,html = "";

for (var i = 0; i < words.length; i++) {
    if (words[i] === "senior")
    html += "<span class='special'>" + words[i] + ((i+1) === words.length ? "" : " ") + "</span>";
    else
        html += "<span>" + words[i] + ((i+1) === words.length ? "" : " ") + "</span>";
   };
$el.html(html).children().hide().each(function(i){
 // if $('span.special')
  $(this).delay(i*200).fadeIn(700);
 // else (normal span)
  $(this).delay(i*600).fadeIn(900);
}).promise().done(function(){
       $('.example:first').html(orig)
    })

How can I tell the difference between the spans with and without the class within my ‘each’ call?

the working demo is here : http://jsfiddle.net/6czap/15/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:54:55+00:00Added an answer on June 8, 2026 at 12:54 pm

    I believe you’re looking for .hasClass:

    $el.html(html).children().hide().each(function(i){
      if($(this).hasClass('special'))
          $(this).delay(i*200).fadeIn(700);
      else
          $(this).delay(i*600).fadeIn(900); 
    }).promise().done(function(){
           $('.example:first').html(orig)
    });
    

    Demo

    However, if you only want to fade in the .special elements use

    $el.html(html).children('.special').hide().each(function(i){
      if($(this).hasClass('special'))
          $(this).delay(i*200).fadeIn(700);
    }).promise().done(function(){
           $('.example:first').html(orig)
    });
    

    instead (see .children, demo).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Table1 user,city Table2 user,friends I want to select * from Table1 for one specific
I want to select one record at a time from a MySQL table. I
I have a One to Many relationship. I want to select all records from
I want to select a specific percentage of data from a matrix. How to
I want to select everything from table one, which contains a column JID. These
I want to select a row from mysql which matches a specific id. I
I want to select only specific attributes from a model(id,name). The SQL-command can be
I want to select a specific range of elements within my XML files Here
i have three tables, i want to select all data from one of the
Using JPA, I want to select all Log objects for a specific actiontype. From

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.