The issue is best described by example:
JS:
$(function () {
$('.classA').on('click', function () { functionA() );
$('.classB').on('click', function () { functionB() });
}
var functionA = function()
{
alert('I am function A');
$('.classA, .classB').toggleClass('classA classB');
}
var functionB = function ()
{
alert('I am function B');
$('.classA, .classB').toggleClass('classA classB');
}
The problem is simply put but hard for me to fix: as expected, after pressing class A div, function A is called, class A is toggled to class B, but next time I press the same div, function A is still called, whereas I expect function B to be called then. I am doing something wrong ???