如何使用jQuery仅禁用JSP上的某些链接

如何使用jQuery仅禁用JSP上的某些链接,jquery,Jquery,我一直在使用JSP上的循环调用三个不同的Struts操作,但打印相同的数据参数: <a href="customize_business?method=add&listingId=<%=biz.getListingId()%>&bid=<%=bid `%>&source=<%=biz.getSource()%>" class="ajax-link-add" id="addBus"><img` `src="../imag

我一直在使用JSP上的循环调用三个不同的Struts操作,但打印相同的数据参数:

<a href="customize_business?method=add&listingId=<%=biz.getListingId()%>&bid=<%=bid `%>&source=<%=biz.getSource()%>" class="ajax-link-add" id="addBus"><img` `src="../images/green-tick.png" /></a>
因此,输出将是:

CitySearch Mexican Village Restaurant 'a link to save in db' 'a link to delete from db' Yelp Mexican Village Restaurant 'a link to save in db' 'a link to delete from db' YahooLocal Mexican Village Restaurant 'a link to save in db' 'a link to delete from db' 是的……如果我有

Source: Citysearch 
Mexican Village Restaurant              add  delete
Mexican Town Restaurant                 add  delete
Chinese Restaurant                      add  delete

Source: Yelp
Mexican Village Restaurant              add  delete
Mexican Town Restaurant                 add  delete
Chinese Restaurant                      add  delete
一旦用户单击CitySearch:Mexican Village Restaurant的“添加”,所有其他仅CitySearch的记录都将变灰,其添加/删除链接将被禁用。只有CitySearch:Mexican Village Restaurant的“删除”链接应该处于活动状态,用户可以从数据库中删除该记录并选择其他业务。当用户选择其他业务时,同样的事情也会发生。其他业务已禁用并灰显,但针对特定选定业务的删除链接应处于活动状态


同时,Yelp和其他来源上的所有添加/删除链接都应处于活动状态。

您只需引用活动元素:

alert("in jquery fro add");
var oLink = $(this);
$.get( $(this).attr('href'), function(msg) {
    if (msg != null) {
        alert($.getAnchorValue('source', oLink.attr('href')));
        oLink.fadeTo('slow', 0.5, function() {
            oLink.removeAttr("href");
        });
    }
});
return false;
编辑:要仅禁用某组链接,请首先将源添加为自定义属性:

<a href="customize_business?method=add&listingId=<%=biz.getListingId()%>&bid=<%=bid `%>&source=<%=biz.getSource()%>" class="ajax-link-add" id="addBus" source="<%=biz.getSource()%>">

在多个元素上使用相同的id addBus。你不应该那样做。这不会解决你的问题,但我只是说,谢谢。但这将仅禁用已单击的链接。我想禁用该特定源的特定循环中的所有链接。尽管所有其他来源中的链接都应该被激活,谢谢。它起作用了,只有源代码上的一个循环中的链接被禁用。每个链接都有一个“检查”和“交叉”,用于从数据库中添加和删除业务。一旦用户检查特定源上的业务,该源的所有链接都将使用上述代码禁用。我在“交叉”链接中添加了相同的代码。但我只想保持一个“交叉”处于活动状态,以便用户删除所选业务。对不起,我不明白你的意思。什么是交叉链接?在代码中看不到任何引用..交叉链接表示删除链接。
Source: Citysearch 
Mexican Village Restaurant              add  delete
Mexican Town Restaurant                 add  delete
Chinese Restaurant                      add  delete

Source: Yelp
Mexican Village Restaurant              add  delete
Mexican Town Restaurant                 add  delete
Chinese Restaurant                      add  delete
alert("in jquery fro add");
var oLink = $(this);
$.get( $(this).attr('href'), function(msg) {
    if (msg != null) {
        alert($.getAnchorValue('source', oLink.attr('href')));
        oLink.fadeTo('slow', 0.5, function() {
            oLink.removeAttr("href");
        });
    }
});
return false;
<a href="customize_business?method=add&listingId=<%=biz.getListingId()%>&bid=<%=bid `%>&source=<%=biz.getSource()%>" class="ajax-link-add" id="addBus" source="<%=biz.getSource()%>">
oLink.fadeTo('slow', 0.5, function() {
    $("a[source='" +  oLink.attr("source") + "']").removeAttr("href");
});