Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Mostrar cuadro de texto oculto cuando se hace clic en dos cuadros de opción Y botón

Aquí está el código HTML de los dos botones de radio y el botón

 <body> <input data-image="small" type="radio" id="small" name="size" value="20" class="radios1"> <label for="small"><span></span></label> <div class="label">Small</div> <input data-image="green" data-image1="small_green" type="radio" id="green" name="color" value="0" class="radios2" > <label for="green"><span></span></label> <div class="label">Green</div> <button type="button" class="cart-btn" id="cartbutton" name="cart" value="5">Add To Cart!</button> </body>

Aquí está el guión que tengo hasta ahora. Conseguí que funcionara solo con los botones de opción, pero cuando agregué la secuencia de comandos del botón, dejó de funcionar.

 <script> const sizeSelector = 'input:radio[name=size]'; const colorSelector = 'input:radio[name=color]'; const cartSelector = 'input:button[name=cart]'; $(function () { // We can add the click event to all radio buttons by linking // their selectors with commans. $(`${sizeSelector}, ${colorSelector}, ${cartSelector}`).click(() => { toggleWhenSmallAndGreenAndCartButton(); }); }); const SMALL = 20; const GREEN = 0; const CARTBUTTON = 5; function toggleWhenSmallAndGreenAndCartButton(){ let size = $(`${sizeSelector}:checked`).val(); let color = $(`${colorSelector}:checked`).val(); let cart = $(`${cartSelector}:selected`).val(); $('#itemdv').toggle(size == SMALL && color == GREEN && cart == CARTBUTTON) && $('#itemdv2').toggle(size == SMALL && color == GREEN && cart == CARTBUTTON); } </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

su selector de botón es incorrecto, no es un tipo de entrada. cámbielo a 'botón [nombre = carrito]'

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!