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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:20:32+00:00 2026-06-08T07:20:32+00:00

i have jquery code that finds src attribute of all images in div (every

  • 0

i have jquery code that finds “src” attribute of all images in div (every image has same class: .image_class), then sends it to ajax (and then to php file that finds that images and delete them).
Here is code:

$remove_images = $.each($("#main_div").find(".image_class").attr(""));
$.ajax({
    type: 'POST',
    data: {
        action: 'delete_images',
        imagefile: $remove_images
    },
    url: 'delete.php',
    success: function(msg) {
        alert("" + msg + "");
    }
})

PHP file looks like this:

  if($_POST["action"]=="delete_images"){
    @unlink($_POST['imagefile']);
  }

But this does not work. I suspect something is wrong in $remove_images (lets say “$.each is bad).

  • 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-08T07:20:35+00:00Added an answer on June 8, 2026 at 7:20 am

    You can use the .map() method to collect stuff from a jQuery collection.

    The callback will run for every element in the collection that is returned by .find() in our case. this will represent the current DOM element. Whatever you return from the callback will be included in the result.

    var $remove_images = $("#main_div").find(".image_class").map(function () {
        return $(this).attr('src');
    }).get();
    

    jsFiddle Demo

    I used the .get() method to convert the result into a plain Javascript array.

    Please read the manual of .map() for further information (and in general, get used to using the manual, because you could have found the answer to your question there – the examples are great in most cases).

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

Sidebar

Related Questions

I have a jQuery function that finds all the images nested in a container
I have some jQuery code that finds elements with the shaded CSS class and
I have a simple jQuery code that runs on a web page that has
I have a jquery line of code that outputs some HTML to a div.
I have the following jQuery code that finds out the width of container and
I have some jquery code that is doing an ajax lookup and returning comma
I have some jQuery code that highlights a link when clicked, and changes the
I have some jQuery code that intercepts links clicked on a page: $(document).ready(function() {
I have some jQuery code that is having difficulty running because I'm using it
I have a Jquery code that is following: var selectedQuestions = $(#SelectedQuestions); var selectedCustomQuestions

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.