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

  • SEARCH
  • Home
  • 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 4272838
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:37:53+00:00 2026-05-21T07:37:53+00:00

Basic idea of what im after.. On document ready copy classes from #box-one into

  • 0

Basic idea of what im after..

On document ready copy classes from “#box-one” into “#box-three” if “#box-two img” has the same image name as “#box-one img”

and if possible.. with the possibility of excluding specific classes from transferring

html:

<span id="box-one" class="first second third">
   <img src="imagefolder/image1.jpg" alt />
</span>

<span id="box-two">
   <img src="imagefolder2/image1.jpg" alt />
</span>

<span id="box-three"></span>

Keeping in mind that the images inside “#box-one” and “#box-two” change but are always identical.

I have no idea how to do this as far as the js goes.. How could this be done?

  • 1 1 Answer
  • 2 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-05-21T07:37:54+00:00Added an answer on May 21, 2026 at 7:37 am
    $(document).ready(function(){
    
        var classesToIgnore = ["second"];
    
        if($("#box-one > img").attr("src").split('/').pop() == $("#box-two > img").attr("src").split('/').pop()) {
           //Get all classes into an array
           var classes = $("#box-one").attr("class").split(" ");
           //Grep out the classes you dont want and join it into a string seperated by space
           classes = $.grep(classes, function(class, index){
               return ($.inArray(class, classesToIgnore));
           }).join(" ");
           //Overwrite #box-three's classes. If you want to append them, loop over the array and use $("#box-three").addClass("className");
           $("#box-three").attr("class", classes);
        }
    
    });
    

    Working example: http://jsfiddle.net/raPBy/

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

Sidebar

Related Questions

I am designing a GUI that has the following basic idea (similarly modeled after
The basic idea is that: I'm downloading encrypted image file from internet and start
I've implemented a paypal transaction before but this one has a twist that I'm
The basic idea of the program is that it searches a large list for
I understand how IPN works, and the basic idea of the sending of information,
I am after a general purpose unspecialised plain text file extractor. Firstly before people
Need: Ability to dynamically build Forms Structure (simple idea not actual structure) Admin: Form
I have been playing around with yasm in an attempt to grasp a basic
Im wondering if someone might be able to help me with something that i
I am absolute beginner in C#, ASP.NET and MVC2 and this means that I

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.