What I want to do is; without leaving the chain, execute some custom/external code (and continue) within the chain. Otherwise; in a deep chain, I will have to re-query for the DOM element to get back where I've left.The method below allows to execute custom code inside a jQuery chain synchronously or asynchronously.//Execute code inside a jQuery chain$.fn.do = function (callback, async) {    if (typeof callback === 'function') {        if (async === true) {            this.queue(function() {                callback($(this));                $(this).dequeue();            });        } else {            callback(this);        }    }    return this;};Simplified Usage Example:var results = {};$('#some-elem')    .css({        //modify some styles here    })    .do(function($elem) {        //do some calculations.. tests here..        //save them to results object    }, false) //synchronous    .css({        //re-set the styles back to their initial state    });This could be a longer chain where you could need to enter the do() method multiple times.So; Do you think the approach above is legitimate?Would you suggest an alternate? Why?
$.fn.do() method: Execute other code within a jQuery chain
javascript;jquery