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 7784427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:05:36+00:00 2026-06-01T20:05:36+00:00

A user specifies a numerical value; then a for loop runs it that many

  • 0

A user specifies a numerical value; then a for loop runs it that many times. I have a series of these types of set ups, and they all work, except this one. I believe it’s because of the :first selector I’ve used.

    jQuery.fn.removeX = function() {
        for (var i = 0; i < xTimes; i++) {
            $("#Tell").append(' removed!');
            $("#List_" + C_user + " img:first").relocate();
        }
    }

I’ve tried variations, such as :nth-child(0), even .slice(), but so far nothing works. However, the .relocate function, it’s designed only to handle one element at a time. I didn’t think should make a difference, but if I switch it out for something like .appendTo, it works fine.

The .relocate script:

    jQuery.fn.relocate = function(){
        getSRC2 = $(this).find('img').attr('src');
        $(this).prependTo(".List_" + Owner).removeAttr('style');
        $(this).remove();
    }

It’s nothing special, so I’m not sure how it breaks the other one.

Any tips/pointers would be helpful.

SOLUTION

Removed the .find(), worked, thanks! I was trying to reuse the script, but the objects it was originally designed for are wrapped, hence the .find().

  • 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-01T20:05:37+00:00Added an answer on June 1, 2026 at 8:05 pm

    Here, you’re selecting an img…

    $("#List_" + C_user + " img:first").relocate();
    

    Then in .relocate(), you’re doing a .find() on the img…

    getSRC2 = $(this).find('img').attr('src');
    

    An img can’t be nested inside an img.


    Either get rid of the .find('img') since you already have it, or get rid of the img part of the selector…

    $("#List_" + C_user).relocate();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SqlDataSource that updates whenever a user specifies a value. I'm trying
I have a variable that a user specifies $start_date in format of y-m-d .
I've created a custom user control that has several properties. One specifies which database
I've got an existing simple MFC app that the user specifies the input file,
I have a feature where I save a file to a location that user
Here's a scenario: There are users, users have skills. If a user specifies new
My main form in my application has a datagrid view that can have 1
I need some help. I have a UITableView that has cells that hold the
I have a multidimensional array that contains a variable number of sub arrays. Each
I'm working on a photo app that needs to save images with user specified

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.