我的代码以编程方式创建<span>
具有自定义 ID 的节点。我正在尝试使用 Jquery 访问特定的,但它不想为我工作。
的HTML:
<div id="container">
<div id="header">
<span id="menu">
</span>
<center></center>
<span id="refresh" runat="server">
</span>
</div>
<div id="content" runat="server">
<ul id="list" runat="server"></ul>
</div>
<div id="article" runat="server">
</div>
</div>
jQuery:
$(document).ready(function () {
$("a").click(function () {
var post = $(this).data('postid'); //this works and returns the postID selected.
$('#list').slideUp(); //this hides all the anchor tags
$('#' + 'post' + post).show(); //This is what is not working
});
});
.net c#
foreach (SyndicationItem item in feed.Items)
{
subject[count] = item.Title.Text;
date[count] = item.PublishDate.DateTime.ToString();
summary[count] = item.Summary.Text;
list.InnerHtml += "<a href=\"#\" data-postid=\"" + count +"\"><li id=\"post" + count + "\"><span id=\"bold\">" + subject[count] + "</span><br>" +
"<span id=\"posted-date\">Posted on: " + date[count] + "</span></li></a>";
article.InnerHtml += "<span style=\"display: none;\" class=\"post\" id=\"post" + count + "\">" + summary[count] + "</span><br>";
count++;
}
几乎当我单击一个锚节点时,它会抓取 postID 并隐藏我拥有的锚标签列表,并假设显示(取消隐藏)具有 postID 的帖子。
如果您需要更多信息,请告诉我。