title: Dynamically change tooltip custom-class
body: <p>I want to dynamically change data-custom-class depending on user's provided data on an specific input field (i.e. if user do not provide at least 1 char for "username", tooltip must be red with some text, if user provide a valid "username", tooltip must be green with some other text).</p>
  
  <p>The problem is that text is in fact changing, but class is not (it keeps the first class set by JQuery.</p>
  
  <p>I've already tried attr() and tooltip(options) - (i.e. "data-customClass" via attr() or customClass via tooltip()). As you can see, I'm even trying to force tooltip disposal and also remove attribute before set it again, but none of that seems to do the work.</p>
  
  <p>Tooltip creates a new "div" and even though it changes the attribute "text", the "custom-class attribute it does not.</p>
  
  <p><strong>NOTE</strong>: I'm using the Bootstrap 4 + Popper.js + The Bootstrap Custom Class (Js + CSS) extension.
  <a href="https://www.jqueryscript.net/tooltip/Custom-Classes-Bootstrap-Tooltips.html" rel="nofollow noreferrer">extension files link here</a></p>
  
  <p>I'll appreciate if you guys have any tips on that!</p>
  
  <p>Tks in advance.</p>
  
  <p>ORIGINAL HTML:</p>
  
  <pre><code>&lt;form action="/register" method="post"&gt;
      &lt;div class="form-group row flex-v-center"&gt;
          &lt;div class="col-xs-3 col-sm-2 text-left"&gt;
              &lt;label for="username"&gt; Username: &lt;/label&gt;
          &lt;/div&gt;
          &lt;div class="col-xs-5 text-left"&gt;
              &lt;input name="username" id="username" type="text" class="form-control-sm" data-custom-class="tooltip-danger" data-togle="tooltip"&gt;
                  &lt;small id="usrndHelpBlock" class="d-block form-text text-muted"&gt;
                          Username must be at least 1 character long and must not be already registered.
                      &lt;/small&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group row flex-v-center"&gt;
              &lt;div class="col-xs-3 col-sm-2 text-left"&gt;
                  &lt;label for="pwd"&gt;Password: &lt;/label&gt;
              &lt;/div&gt;
              &lt;div class="col-xs-5 text-left"&gt;
                  &lt;input name="password" id="pwd" type="psw" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" class="form-control-sm" data-toggle="tooltip" data-placement="aright" data-custom-class="tooltip-primary" title=""&gt;
                      &lt;small id="passwordHelpBlock" class="d-block form-text text-muted"&gt;
                          Password must be at least 8 characters long , contain letters and numbers, and must not contain spaces, special characters, or emoji.
                      &lt;/small&gt;
              &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group row flex-v-center"&gt;
          &lt;div class="col-xs-3 col-sm-2 text-left"&gt;
              &lt;label for="conf"&gt;Confirmation: &lt;/label&gt;
          &lt;/div&gt;
          &lt;div class="col-xs-5 text-left"&gt;
              &lt;input name="confirmation" id="conf" type="text" class="form-control-sm" data-toggle="tooltip" data-placement="auto" data-custom-class="tooltip-primary" title="Confirmation doesn't match password!"&gt;
                  &lt;small id="confHelpBlock" class="form-text text-muted"&gt;
                      Confirmation must match password.
                  &lt;/small&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group row flex-v-center"&gt;
          &lt;div class="col-xs-8"&gt;
              &lt;button id="b_register" class="btn btn-primary"&gt;Register Now !&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>SCRIPT</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $('#username').focusout(function() {
          if ($('#username').val() == "") {
              $('#username').tooltip('dispose');
              $('#username').attr("title","User must be at least 1 character long!");
              $('#username').tooltip('toggle');
              $('#username').focus();
          } else {
              $('#username').tooltip('dispose');
              $('#username').removeAttr("data-custom-class");
              $('#username').attr("data-custom-class", "tooltip-success");
              $('#username').attr("title","Username avaiable!");
              $('#username').tooltip('dispose');
              $('#username').tooltip('toggle');
          }
      });
  &lt;/script&gt;
  </code></pre>