我有以下代码,其功能类似于 Stackoverflow 上评论链接的工作方式...单击时,它会触发 ActionResult 并填充 div
$(function() {
$("a[id ^='doneLink-']").live('click', function(event) {
match = this.id.match(/doneLink-(\d+)/);
container = $("div#doneContainer-" + match[1])
container.toggle();
if (container.is(":visible")) {
container.load($(this).attr("href"));
} else {
container.html("Loading...");
}
event.preventDefault();
});
});
我希望能够做一件事,更改他们单击的链接文本以显示“隐藏”之类的内容,并禁用此链接所在的小菜单中的其他链接。
编辑: 该函数的源代码如下所示
<div id="dc_lifelistmenu"style="float:left;padding-bottom:5px;font-size:10pt;width:400px;">
<a href="/entries/addentry/86">Add Entry</a> |
<a href="/goals/adddaimoku/86" id="daimokuLink-2">Log Daimoku</a> |
<a href="/goals/done/86" id="doneLink-2">Mark Completed</a> |
<a href="/goals/remove/86">Remove</a>
</div><br />
<div id='daimokuContainer-2' style="display:none;"> Loading...</div>
<div id='doneContainer-2' style="display:none;"> Loading...</div>
最佳答案
如果您想删除链接而不是禁用它:
jQuery('#path .to .your a').each(function(){
var $t = jQuery(this);
$t.after($t.text());
$t.remove();
});
注释:
关于jquery - 使用 JQuery 禁用链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/586024/