admin管理员组文章数量:1334360
I have trouble with my jquery disabling my linkbutton from clicks after the first click has taken place.
The click should also remove and add some cssStyles.
The problem is no that the linkbutton (anchortag rendered in html) dosent get disabled after the cssStyles has been changed.
After a postback(triggered manually by me) it goes disabled. but that is not something i want. i want it to be a smooth transaction and no postback.
MarkupCode:
<asp:LinkButton ID="LinkButton" runat="server" OnClientClick="" CommandName="Answer" CssClass="linkButton" >
<asp:Panel ID="PoptionText" runat="server" CssClass="buttonStyle">
<%# Eval("optionText") %>
<div>
<asp:Label ID="lbRätt" runat="server" Visible="false" CssClass="aktiv"></asp:Label>
</div>
</asp:Panel>
</asp:LinkButton>
Javascript code:
$(document).ready(function () {
$("#LinkButton").click(function () {
$("#LinkButton").attr("disabled", "disabled"); //this does not happen
Rightanswer(); // This happens. Function to add remove cssStyles
})
$("#LinkButton").click(function (e) {
if ($("#LinkButton").attr("disabled") == "disabled") {
e.preventDefault();
}
});
});
I have trouble with my jquery disabling my linkbutton from clicks after the first click has taken place.
The click should also remove and add some cssStyles.
The problem is no that the linkbutton (anchortag rendered in html) dosent get disabled after the cssStyles has been changed.
After a postback(triggered manually by me) it goes disabled. but that is not something i want. i want it to be a smooth transaction and no postback.
MarkupCode:
<asp:LinkButton ID="LinkButton" runat="server" OnClientClick="" CommandName="Answer" CssClass="linkButton" >
<asp:Panel ID="PoptionText" runat="server" CssClass="buttonStyle">
<%# Eval("optionText") %>
<div>
<asp:Label ID="lbRätt" runat="server" Visible="false" CssClass="aktiv"></asp:Label>
</div>
</asp:Panel>
</asp:LinkButton>
Javascript code:
$(document).ready(function () {
$("#LinkButton").click(function () {
$("#LinkButton").attr("disabled", "disabled"); //this does not happen
Rightanswer(); // This happens. Function to add remove cssStyles
})
$("#LinkButton").click(function (e) {
if ($("#LinkButton").attr("disabled") == "disabled") {
e.preventDefault();
}
});
});
Share
Improve this question
asked Apr 9, 2013 at 13:45
J.OlssonJ.Olsson
8153 gold badges13 silver badges29 bronze badges
0
2 Answers
Reset to default 2You can also try this one out:
$("#<%=LinkButton.ClientID %>").click(function (e) {
e.preventDefault();
$(this).attr("disabled", "disabled");
// Whateverr your code goes here
});
You cant use disabled
attribute with anchor tag, only input
elements have disabled
attribute. You can try something like
$("#LinkButton").click(function (e) {
if ($("#LinkButton").hasClass(className)) {
// If have class dont follow href so will work only for first time
e.preventDefault();
}
Rightanswer(); // Add / Remove class
});
This might help Should the HTML Anchor Tag Honor the Disabled Attribute?
本文标签: Disable linkbutton (anchor tag) with jqueryStack Overflow
版权声明:本文标题:Disable linkbutton (anchor tag) with jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742345240a2457390.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论