Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I get the text of these anchor tags to use for the next page?

HTML
<div class = "cont-holder"style="removed-118px;removed50px;height:50%;width:30%;removed:relative;color:#FFFFFF;float:right;margin-removed 75px;">
                                <ul>
          <li>    <a href=reports.php><h2 style="font-family:Tahoma; text-align:left;"> Daily Reports </h2></a></li>
          <li>    <a href=reports.php><h2 style="font-family:Tahoma; text-align:left;"> Weekly Reports </h2></a></li>
          <li>    <a href=reports.php><h2 style="font-family:Tahoma; text-align:left;"> Monthly Reports </h2></a></li>
          <li>    <a href=reports.php><h2 style="font-family:Tahoma; text-align:left;"> Yearly Reports </h2></a></li>
          <li>    <a href=reports.php><h2 style="font-family:Tahoma; text-align:left;"> Cancelled Transaction Reports </h2></li>
        </ul>

    </div>


I need to set the text like daily reports as the title for the next page. THanks.
Posted

1 solution

give your ul an id
and then you can do the query below:

JavaScript
var arr=array();
var i=0;
var lists=document.querySelector("#ul_id").querySelectorAll("li");
[].forEach.call(
lists, 
  function(li){
    array[i]=li.querySelector("h2").innerHTML;
  }
);


there may be some syntax error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900