C.Ronaldo C.Ronaldo - 1 year ago 180
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()

Answer Source

.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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download