Hi, I have the next code to work on ASP.Net controls.
I'm trying to add some javascript code to "onclick" event on a button when the result variable(res) is equals to "NO". The issue is that the first time it assigns the value to "onclick" it works fine, but when the removeAttr is executed and again the function is call and the res is equals to "NO" again it doesn't add the code on "onclick" event. So what's wrong on this? Thanks for your help. =)
Legend: - HLevel(Textbox) - PSave(LinkButton)
$('#HLevel').blur(function () {
// SOME CODE HERE BEFORE THE ISSUE CODE
var res = $(msg).find("string").text();
if (res == "NO") {
$('#PSave').attr("onclick", "javascript:return confirm('some text');");
} else {
$('#PSave').removeAttr("onclick");
}
});