多个jQuery选择器 [英] Multiple jquery Selectors
问题描述
感谢 karim79 ,我能够点击ImageButton
并将jQuery高亮效果应用于其他div
$("#btnFavorite").click(function() {
// selector for element to highlight
$("#theDiv").effect("highlight", {}, 3000);
});
现在我想将问题扩展如下.
我将ImageButtons
动态地添加到网页中,并且我希望在每次点击ImageButton
时在div
上应用效果.
<asp:ListView ID="ListView1" runat="server">
<layouttemplate>
<asp:PlaceHolder id="itemPlaceholder" runat="server" />
</layouttemplate>
<ItemTemplate>
<asp:ImageButton ID="btnFavorite" runat="server" ImageUrl="~/Images/Favorite.png"/>
</ItemTemplate>
</asp:ListView>
在这种情况下我该怎么办?通过使用列表视图的ItemDataBound
并添加属性
像
btnFavorite.Attributes.Add("onmouseclick", "doSomething")
还是什么?
我完全迷路了!
您可以尝试使用更通用的选择器,例如
$("input[type='image']").click(function(){
$(".. related div selector ..").effect("highlight", {}, 3000);
});
我不知道div
和input
之间的关系,所以我不能假设选择器是什么,但是如果您发布该关系或对其进行解释,我们可以帮助您编写更准确的选择器. /p>
值得注意的是,如果在DOM加载后而不是在服务器端将 Thanks to karim79 i am able to click on the Now i would like to extend the question as follows. I add the What should i do in that case? By using I am totally lost! You could try a more generic selector like this... I don't know the relationship between the It should be worth noting that if you are dynamically added the
这篇关于多个jQuery选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!ImageButton
动态添加到页面中,那么您可能希望使用ImageButton
and apply the Jquery highlight effect to a different div
$("#btnFavorite").click(function() {
// selector for element to highlight
$("#theDiv").effect("highlight", {}, 3000);
});
ImageButtons
to the webpage dynamically, and i would like to apply the effect on the div
for every ImageButton
click. <asp:ListView ID="ListView1" runat="server">
<layouttemplate>
<asp:PlaceHolder id="itemPlaceholder" runat="server" />
</layouttemplate>
<ItemTemplate>
<asp:ImageButton ID="btnFavorite" runat="server" ImageUrl="~/Images/Favorite.png"/>
</ItemTemplate>
</asp:ListView>
ItemDataBound
of the listview and adding attributes
like btnFavorite.Attributes.Add("onmouseclick", "doSomething")
or what?$("input[type='image']").click(function(){
$(".. related div selector ..").effect("highlight", {}, 3000);
});
div
and the input
so I can't assume what the selector is but if you post the relationship or explain it we can help you write a more accurate selector.ImageButton
s to the page after the DOM has loaded and not on the server side then you would likely want to use the live
method for attaching events... $("input[type='image']").live('click', function(){
$(".. related div selector ..").effect("highlight", {}, 3000);
});