【发布时间】:2009-01-20 05:12:29
【问题描述】:
如何使下面的函数更加动态,例如commentLink 和commentContainer 后面会有一个ID,像这样commentLink-2289 commentContainer-2289 因为会有多个列表中的。
Javascript
$(function() {
$("#commentLink").click(function()
{
$("#commentContainer").toggle();
if ($("#commentContainer").is(":visible"))
{
$("#commentContainer").load($(this).attr("href"));
} else
{
$("#commentContainer").html("Loading..."); //Or just leave it as is...
}
return false; //Prevent default action
});
});
HTML
<div id="SystemNews">
<ul id="dc_news">
<li>
<a href="/Home/SystemNews/69" id="commentLink-0">Comments</a>
<div id='commentContainer-0' style="display:none;"> Loading...</div>
</div>
</li>
</ul>
</div>
注意:请提供一个工作示例,我通过示例学习最好,谢谢
【问题讨论】:
-
你到底为什么要把这个问题作为一个新问题打开?这完全违背了 Stack Overflow 的目的。
-
因为我在问一个问题......我需要知道我哪里出错了?
-
对,但是使用问题/答案的堆栈溢出格式,而不是问题,问题,问题。它完全违背了该站点的目的,并使其他用户更难使用。您的答案发布在下面,没有错误。
标签: jquery asp.net-mvc