Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

336
Visualizações
Changing values when a button is pressed, [multiple choices]

I have the following code inside a POST form. When someone clicks on the input the value of pricing changes to the one the user has clicked.

The input class is just a method of altering the CSS once clicked - so you can see which was clicked last.

(function() {
  $(function() {
    var toggle;
    return toggle = new Toggle('.toggle');
  });

  this.Toggle = (function() {
    class Toggle {
      constructor(toggleClass) {
        this.el = $(toggleClass);
        this.tabs = this.el.find(".hs_pricing_toggle");
        this.panels = this.el.find(".panel");
        this.bind();
      }

      show(index) {
        var activePanel, activeTab;
        //update tabs
        this.tabs.removeClass('activate');
        activeTab = this.tabs.get(index);
        $(activeTab).addClass('activate');
        //update panels
        this.panels.hide();
        activePanel = this.panels.get(index);
        return $(activePanel).show();
      }

      bind() {
        return this.tabs.unbind('click').bind('click', (e) => {
          return this.show($(e.currentTarget).index());
        });
      }

    };

    Toggle.prototype.el = null;

    Toggle.prototype.tabs = null;

    Toggle.prototype.panels = null;

    return Toggle;

  }).call(this);

}).call(this);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="hs_pricing_toggle__wrapper" id="toggle__wrapper">
  <input class="price1 hs_pricing_toggle" type="" id="pricing" name="pricing" placeholder="5" value="5" required/>
  <input class="price2 hs_pricing_toggle" type="" id="pricing" name="pricing" placeholder="10" value="5" required/>
  <input class="price3 hs_pricing_toggle" type="" id="pricing" name="pricing" placeholder="15" value="5" required/>
  <input class="price4 hs_pricing_toggle" type="" id="pricing" name="pricing" placeholder="insert value" required/>

This just changes the CSS of the class 'hs_pricing_toggle' and shows a within the class pannel. Nothing important in this case - I guess.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda