Search code examples
htmlhref

how to get last modified date if you click on link?


I have 2 links here, on clicking any link I need to get last modified date&time beside it ..

<html>
<head>
</head>
<body>
<table border="1">
    <tr>
        <td><a href="" id="1"/a>First
            </td>
            <td>
                <script>document.write(document.lastModified + "")</script>
            </td>
    </tr>
    <tr>
        <td><a href="#" id="2"/a>Second
            </td>
            <td width="200px">
                <script>document.write(document.lastModified + "")</script>
            </td>
    </tr>
</body>
<html>

Solution

  • Try something like

    <html>
    <head>
    </head>
    <body>
    <table border="1">
    <tr>
        <td>
            <a href="#" onclick="ShowDate(1)" id="1" >First</a>
        </td>
        <td>
            <span id="firstDate"></span>
        </td>
     </tr>
     <tr>
        <td>
            <a href="#" onclick="ShowDate(2)" id="2">Second</a>
        </td>
        <td width="200px">
            <span id="secondDate"></span>
        </td>
     </tr>
     <script>
        function ShowDate(location)
        {
            if(location == "1")
            {
                $("#firstDate").innerHtml = Date();
            }
            else if(location == "2")
            {
                $("#secondDate").innerHtml = Date();
            }
        }
      </script>
      </body>
      <html>