【发布时间】:2020-07-27 22:25:28
【问题描述】:
当我点击 p 时,什么都没有发生,但是当我点击 div 的任何其他部分时它工作正常。我不知道为什么会这样。请帮助我。
<%- include('./partials/header');-%>
<%- include('./partials/flash');-%>
<% posts.forEach(function(post){ %>
<a href="/post/<%= post._id %>" id="posta">
<div id="post">
<h3 class="text-dark" id="title"><%- post.Title %></h3>
<p class="text-secondary" id="date"><small><%=post.Author.name %><br>
<%=post._id.getTimestamp().toLocaleDateString()%></small></p>
<p class="h6 text-dark" id="Postcontent"><%- post.Content.substring(0,200)+"..." %><span class="h6 text-success">Read more</span>
</p>
</div>
</a>
<span id="border"></span>
<% }) %>
<%- include('./partials/footer');-%>
我使用的css:
#post:hover{
box-shadow: 0 5px 5px 0 #4CAF50;
text-decoration: none;
}
#posta:hover {
text-decoration: none;
}
#posta:link {
text-decoration: none;
}
#posta:visited {
text-decoration: none;
}
#Postcontent{
font-size: 1rem;
white-space: pre-wrap;
}
更新: 这很奇怪,但我观察到的是,当我点击第一个项目的 p 时它不起作用,但对于所有其他项目它都起作用。
【问题讨论】:
-
对我来说效果很好。它周围是否有其他代码干扰?
-
您关闭
<p>的Read more标记未正确关闭 -
@abney317。感谢您指出错误。尽管纠正了错误,但我遇到了同样的问题。
-
@Kerri 抱歉回复晚了。我会发布完整的代码。
-
请也粘贴以 html 呈现的输出,以便我们为您提供帮助
标签: javascript html jquery css ejs