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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:08:13+00:00 2026-05-23T17:08:13+00:00

I need to get the text that is inside a element. I can only

  • 0

I need to get the text that is inside a element.

I can only grab the class of this element and NOT the ID.

<span class="fileName">test.png</span>

So I need a way to get test.png, but as you see I have only the class of the element and not the ID.

Just notice also that we may have more <span class="fileName"></span>, so it could look like this

<span class="fileName">test1.png</span>
<span class="fileName">test2.png</span>
<span class="fileName">test3.png</span>
<span class="fileName">test4.png</span>

In the case we have more, like the example above, I need to get ALL the values and not only one, because I need to pass this value to another page with jQuery. So it should be able to get one value or more from that element.

Please help!

And also I am not a javascript expert!

  • 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-05-23T17:08:13+00:00Added an answer on May 23, 2026 at 5:08 pm
    var filenames = $('.fileName').map(function(){
        return $(this).text();
    }).get();
    

    The array filenames will contain all the names of the images. You can pass on this array to another jQuery function, or anywhere else you like to do so.

    You can test it here »

    Update

    Since you request the filenames to be a string separated by a comma, you can do it like this:

    var filenames = $('.fileName').map(function(){
        return $(this).text();
    }).get().join(',');
    

    Now, filenames will contain the string test1.png,test2.png,test3.png,test4.png.

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

Sidebar

Related Questions

I want to grab text inside a div element like this : <div class='someclass'>
i have text like this div bla-bla end div i need to get only
HTML is <a>ref</a> I need to get <a>ref</a>text How can i do this? $('a').append('text')
I have an HTML element with only visible text inside. This example is a
I have some elements that need to have the text inside editable, for this
I often have data in Excel or text that I need to get into
I've subclassed an UITextField and inside that, I need to know if the text
I have two tables with a weak relation. I need get a text value
I need to get the Portuguese text content out of an Excel file and
I need to get a list of tags in a text, make their contents

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.