jQuery addClass example

Change class name on click in jQuery

by manu v

HTML

<script src="https://js.chilipiper.com/marketing.js"></script>
<script>ChiliPiper.scheduling("tapclicks", "in-app-test-router", { title: "Thanks! What time works best for a quick call?", titleStyle: "Roboto 22px #EA5938" })</script>

<form id="pardotChiliForm">
  FName:<br>
  <input type="text" name="firstname" value="">
  <br>
  LName:<br>
  <input type="text" name="lastname" value="">
  <br>
  Email:<br>
  <input type="email" name="email" value="">
  <br><br>
  Phone:<br>
  <input type="phone" name="phone" value="">
  <br><br>
  <button type="submit" value="Submit">test</button>
</form>

JavaScript

function tapTrigggerChili(id) {
  if (!id || typeof ChiliPiper !== 'object') return;
  var router = window.chiliPageRouter || 'inbound-router';
  ChiliPiper.submit('tapclicks', router, { 
    formId: id,
    title: 'Thanks! What time works best for a quick call?', 
    titleStyle: 'Roboto 22px #EA5938',
    // adding lead data here wipes all auto scraped
    // lead: {
    //   Phone: '+33344444444'
    // }
  });
  
     var $form = $('#pardotChiliForm');
    $form.submit(function(e){
      e.preventDefault();
      
      var button = $form.find('[type="submit"]');
      var buttonText = button.text();
      
      
      pardotSendLead(
        data,
        function(jqXHR){ 
          console.log(jqXHR);
          button.prop('disabled',false).removeClass('disabled').text(buttonText);
          tapTrigggerChili('pardotChiliForm');
        }
      );
    });
  }