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

120
Views
Accediendo al valor del botón de opción fuera de la función en javascript

Necesito el valor del botón de radio fuera de la función.

En el siguiente código, el valor de la variable devuelve un nuevo valor cada vez que se presiona el botón de opción; sin embargo, el valor de la fecha no cambia.

 var date_value=2; var $radios = $('input[name=daterange]').change(function () { var value = $radios.filter(':checked').val(); console.log('value'+value); date_value = value; }); console.log('date value'+date_value);

HTML

 <div id="dates" name="daterange"> <p> <input type="radio" id="d1" name="daterange" value='2'/> <label for="d1">24 hours</label> <br> <input type="radio" id="d3" name="daterange" value='7'/> <label for="d3">7 days</label> <br> <input type="radio" id="d4" name="daterange" value='30'/> <label for="d4">1 month</label> </div>
about 4 years ago · Juan Pablo Isaza
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!