I need to take value, when click on particular link which has id="username" but it does not work...
My attempt:
function rev() {
    var username = (this).getElementById("username").textContent;
    return alert (username);
}
while($trackResultRow = mysqli_fetch_assoc($trackResult)){?>
    <a onclick="rev()"><span class="glyphicon glyphicon-thumbs-down pull-right"></span></a>
    <span class="glyphicon glyphicon-thumbs-up pull-right"></span>
    <li>
        <a href="<?php echo $trackResultRow['track_path']?>"><span id="username"><?php echo $trackResultRow['username']?></span> - <span id="track"><?php echo $trackResultRow['track_name']?></span>
            <span class="glyphicon glyphicon-download pull-right"></span>
            <div class="pull-right">
                <span class="glyphicon glyphicon-pause pull-right" onclick="document.getElementById('aud').pause()"></span>
                <span class="glyphicon glyphicon-play pull-right" onclick="document.getElementById('aud').play()"></span>
            </div>
        </a>
    </li>
    <hr>
<?php
    }
?>
Also I tryed
function rev() {
   var username = document.getElementById(value).textContent;
   return alert (username);
}
 <button id="but" onclick="rev()">hey</button>
 <button id="but" onclick="rev()">hey233</button>
Any ideas?
 
     
     
     
     
    