C.Ronaldo C.Ronaldo - 8 months ago 123
jQuery Question

Callback function on addClass not working

I want the browser to focus on the input after clicking the focus button.

But before that I want it to add a class first and then focus. Is this possible? Or can I only use callback functions on 'animations' like hide, click etc.

I've created a jfiddle: https://jsfiddle.net/6ktgc4h9/5/



$('input').addClass('test', function()


.addClass doesn't have a callback function.

Callbacks are used for asynchronous operations. They aren't needed for synchronous operations. Just execute the code in the order you want it executed: