This
if (document.getElementById("link") == per.FirstName) {
Will never evaluate true. You're comparing a reference to an HTML element to a (I presume) string FirstName
.
I can't fathome why you're trying to do this in javascript when you are server-side rendering the page. Just build the HTML inline
<ul>
<% pers.forEach(function(per) { %>
<li>
<a href="/persons/<%= per.Id%>">
<%= per.FirstName %>
</a>
</li>
<% }) %>
</ul>
Note: Removed Id
from your element as ids should be unique and you're rendering in a loop!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…