Jquery 降低中继器上图像的不透明度

Jquery 降低中继器上图像的不透明度,jquery,asp.net,Jquery,Asp.net,我有一个中继器控件,每个项目模板有一个图像和链接按钮 我想做的是,当点击链接按钮时,除了与点击相关的图像外,其他图像的不透明度为50% <asp:Repeater ID="Categories" runat="server" OnItemCommand="showSubCat_itemCommand"> <HeaderTemplate></HeaderTemplate> <ItemTemplate> <div c

我有一个中继器控件,每个项目模板有一个图像和链接按钮

我想做的是,当点击链接按钮时,除了与点击相关的图像外,其他图像的不透明度为50%

<asp:Repeater ID="Categories" runat="server" OnItemCommand="showSubCat_itemCommand">
    <HeaderTemplate></HeaderTemplate>
    <ItemTemplate>
       <div class="catListing">   
       <img class="RepeaterImage" src="/images/<%#Eval("imageUrl").ToString()  ?? "" %>"/>
       <asp:LinkButton ID="showSubCats" runat="server" text='<%# Eval("Name") %>' CommandArgument='<%# Eval("id") %>'/>   
       </div>
    </ItemTemplate>
    <FooterTemplate></FooterTemplate>
</asp:Repeater>

"/>
这是我的中继器,我希望这样的东西能起作用:

<script type="text/javascript">

$('[ID*="showSubCats"]').click(function () {
    debugger;
       $(".RepeaterImage").not(this).stop().animate({ opacity: 0.4 }, 300);
       $(this).stop().animate({ opacity: 1.0 }, 300);

    });
</script>

$('[ID*=“showSubCats”]')。单击(函数(){
调试器;
$(“.RepeaterImage”).not(this).stop().animate({opacity:0.4},300);
$(this.stop().animate({opacity:1.0},300);
});
单击任何showsubcats链接按钮都不会发生任何情况。我猜我可能走错了方向


任何帮助都很好。

asp:LinkButton
的html标记中的
id
属性将不会是
showSubCats
。 我建议您在
asp:link按钮上设置
CssClass=“showSubCats”
,然后使用以下脚本:

<script type="text/javascript">

    $('.showSubCats').click(function () {

       $(".RepeaterImage").not(this).stop().animate({ opacity: 0.4 }, 300);
       $(this).stop().animate({ opacity: 1.0 }, 300);

    });
</script>

$('.showSubCats')。单击(函数(){
$(“.RepeaterImage”).not(this).stop().animate({opacity:0.4},300);
$(this.stop().animate({opacity:1.0},300);
});

谢谢-我现在点击得到了响应(我发出了一个警告进行检查)。但是,没有一个图像的不透明度降低。我不知道为什么,jQuery语法看起来很好。即使我可能会跳过
.stop()
,或者将参数传递给函数:
.stop(true,true)