title: Dynamically named function call within jQuery chain
body: <p>I have a similar question to <a href="https://stackoverflow.com/questions/969743/how-do-i-call-a-dynamically-named-method-in-javascript">this Stack post</a>; but, would like to call the function in a jquery chain. Here is my pseudo code:</p>
  
  <pre class="lang-js prettyprint-override"><code>function togglePanels(f) {
    var customchain;
    if (f == 'n') {
      customchain = $.next();
    } else {
      customchain = $.prev();
    }
    let $next_or_prev_panel = $current_panel
      .parents("div")
      .eq("2")
      .customchain("div")
      .find(".panel");
  }
  </code></pre>
  
  <p>I imagine the solution will involve prototyping the jQuery library somehow?</p>