I am trying to reopen a closed click event using jQuery but I don't want to refresh my page for it. For better understanding,please take a look at what I really want:
$(function (){
Var i = 0;
Var j =0;
$("#first").on("click" , function (){
i++;
});
$("#second").on("click" , function (){
j++;
});
if(i = j){
$("first").off("click");
}
$("#third").on("click" , function (){
alert("what should I write here to reopen #first ID closed click event, without any refresh or reload");
});
});
After I click my #third ID, I want my #first ID with closed click event to start responding again on click!
Edited |
Why I want to do this: I've to use off() , so that no one can add anything in the list given in my website, by clicking #first ID once the limit is exceeded, and can only be able to do so after removing previous list which is already full ...
I'm not sure I follow the use case, but couldn't you just put an if statement inside the first click and only increment if
idoes not equalj, or only ifiis less thanj?If that works, you can remove the .off()