I have an anchor tag with class “.disable” and script that toggles it to “.enable”.
if((counter.text() < 140) && (counter.text() >= 0)) {
$('#tweet').addClass("enable");
$('#tweet').removeClass("disable");
} else {
$('#tweet').addClass("disable");
$('#tweet').removeClass("enable");
}
The anchor is used to submit a form but only when the class is set to “.enable”.
$(document).ready( function(){
$(".enable").click( function(e){
(e).preventDefault();
$("#myform").submit();
});
});
Howver, this doesn’t work. The second script doesn’t seem to recognise the dynamic .class change. If I change the class in the above code to “.disable”, it works.
Any idea why?
Try this: