this function is called on Load how do i convert this to jquery Anonymous function . I tried but it is giving me Object Expected Error . Moreover I have made call to the below
setTab() in 20 files so i cannot Change the Signature of the calling it should be same as (setTab(“Test”)) but the Implementation needs to be changed to Anonymous function which accepts a parameter.
//old JS func()
function setTab(selection) {
$("#"+selection).css('background', '#CC0000');
$("#"+selection).css('color', '#ffffff');
}
//jquery Anonynous Func
var setsTab = (function (selection) {
$("#"+selection).css('background', '#CC0000');
$("#"+selection).css('color', '#ffffff');
})();
The problem is that you have setup a self executing anonymous function, meaning setsTab is set to what the function returns (undefined) because the function is called as soon as it is made (that’s what the paren group at the end of the statement does, calls the function);
What i would do is