Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

215
Vistas
retrieve the value of a button jquery

I have this:

 <div class="cable-config">
            <span>Select Entries</span>
          
            <div class="cable-choose">
              <button id="Home" value="5.00">50 Entries<br>$5.00</button>
              <button value="10.00">100 Entries<br>$10.00</button>
              <button>250 Entries<br>$25.00</button>
              <button>500 Entries<br>$50.00</button>
            </div>
            <p>By entering, you agree to our Terms of Service, Official Rules, and Privacy Policy.</p>
          </div>
      </div>

      <script>
         var buttonValue = ""
          $('button').on('click', function(){
            $('button').removeClass('active_button');
            $(this).addClass('active_button');
            // var fired_button = $(this).val();
            //  alert(fired_button);
        });

        //Home button active on page load
        $(document).ready(function(){
            $('#Home').addClass('active_button');
        });

what it does it on button click, set the class to active_button.

Now what I am trying to do is get the value of class active_button when I click a new button. As you can see, i try to retrieve the value of active_button, but it returns undefined. what am i doing wrong?

function myfunction() {
  var valueOfButton = $('active_button').val();
  console.log(valueOfButton);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="cable-config">
  <span>Select Entries</span>

  <div class="cable-choose">
    <button id="Home" value="5.00">50 Entries<br>$5.00</button>
    <button value="10.00">100 Entries<br>$10.00</button>
    <button>250 Entries<br>$25.00</button>
    <button>500 Entries<br>$50.00</button>
  </div>
  <p>By entering, you agree to our Terms of Service, Official Rules, and Privacy Policy.</p>
</div>

<div class="product-price">
  <button onclick="myfunction()" class="cart-btn">Continue To Payment</button>
</div>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda