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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:10:08+00:00 2026-05-14T15:10:08+00:00

I have this piece of HTML <div id=fileTreeInviati> <ul class=php-file-tree> <li class=pft-directory> <a href=#

  • 0

I have this piece of HTML

<div id="fileTreeInviati">
<ul class="php-file-tree">
    <li class="pft-directory">
        <a href="#" class="" name="101">A006 - SOMETEXT (<span name="contaNew"></span>)</a>
        <img src="./moduli/home/images/info.png" title="Informazioni Azienda" class="imgInfo"/>
            <ul style="display: none;">
               <li class="pft-file ext-png">
                    <a href="javascript:getInfoFile('4');" class="" id="4">cut.png</a>
               </li>
               <li class="pft-file ext-dll">
                    <a href="javascript:getInfoFile('27');" class="new" id="27">Safari.dll</a>      
               </li>
            </ul>
    </li>
    <li class="pft-directory">
        <a href="#" class="" name="102">A012 - SOMETEXT (<span name="contaNew"></span>)</a>
        <img src="./moduli/home/images/info.png" title="Informazioni Azienda" class="imgInfo"/>    
        <ul style="display: none;">
        <li class="pft-file ext-jpg">
            <a href="javascript:getInfoFile('19');" class="new" id="19">04.jpg</a>   
        </li>   
        <li class="pft-file ext-dll">
            <a href="javascript:getInfoFile('24');" class="new" id="24">Safari.dll</a>   
        </li>
      </ul>
    </li>
    <li class="pft-directory">
       <a href="#" class="" name="103">A014 - SOMETEXT (<span name="contaNew"></span>)</a>
         <img src="./moduli/home/images/info.png" title="Informazioni Azienda" class="imgInfo"/>    
       <ul style="display: none;">   
         <li class="pft-file ext-txt">
            <a href="javascript:getInfoFile('17');" class="new" id="17">acu.txt</a>   
             </li>   
         <li class="pft-file ext-dll">
              <a href="javascript:getInfoFile('22');" class="new" id="22">Safari.dll</a>  
         </li>
       </ul>
    </li>
</ul>

I’m working on a js snippet that cycle through all “a” of the “li” and checks if it has the class “new” if yes increment a counter by one. This counter now has to be printed on the relative “li” “span” 3 level before.
So I have the number of the element with the “new” class.
The js snippet is this

$("#fileTreeInviati .php-file-tree .pft-directory li").each(function(){
$(this).children("a").each(function(i,e){
    if ($(e).hasClass("new")){
        cont++;
        console.log($(e).text());
        $(this).parent().parent().parent().children("a").children("span").text(cont);    
    }
})
cont = 0;

});

I think I’m almost there but the counter is always 1. I think there is something mess with .children, maybe it can handle only the first occurrence?
Thanks for help

  • 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-14T15:10:09+00:00Added an answer on May 14, 2026 at 3:10 pm

    OK, I figure out how to do the magic:)
    Here it is:

    cont = 0;
    $('#fileTreeInviati .php-file-tree .pft-directory').each(function() {
        $(this).children("ul").children("li").children("a.new").each(function(i,e){
            cont++;
            $(e).parent().parent().parent().children("a").children("span").text(cont);  
        });
    cont=0;    
    });
    

    Now all works perfect. If you think this can do in a better way, lemme know.
    Bye

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

Sidebar

Related Questions

I have this piece of code: <li class=selected><a href=/AmIACandidate.html>Am I a Candidate?</a></li> I need
I have this piece of html in my page. <p><a href=# id=addQueryPart >Add</a></p> <div
I have this piece of html in my page. <p><a href=# id=addQueryPart >Add</a></p> <div
I have a piece of piece of HTML which looks like this - <div
I'm making a website and I have this HTML for a bar chart: <div
I have this piece of code (summarized)... AnsiString working(AnsiString format,...) { va_list argptr; AnsiString
I have this piece of Javascript and it just won't work. I allready checked
I have this piece of code #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h>
I have this piece of code: $(#faq).click(function () { var url = $.get(faq, {
I have this piece of code: var myObj = function () { this.complex =

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.