live
is deprecated, so don't try to use it anymore, use on
instead.
toggle
event is deprecated anche can't be used anymore as click handler, in this case you can check if your element have a class as identifying element.
Ref:
Note: This method signature was deprecated in jQuery 1.8 and removed in jQuery 1.9. jQuery also provides an animation method named .toggle() that toggles the visibility of elements. Whether the animation or the event method is fired depends on the set of arguments passed.
To switch the classes you can use toggleClass
with multiple classes.
Code:
$("#validate").on('click', function (e) {
e.preventDefault();
$(this).toggleClass('red-stripe green-stripe');
($(this).hasClass('red-stripe')) ? $(this).html('Validate') : $(this).html('Validated');
});