A
A
artshelom2017-03-08 19:38:52
JavaScript
artshelom, 2017-03-08 19:38:52

How to know which radio is activated??

There is this code:

<input id="results-alltime" type="radio" name="results-tabs"  checked>
            <label id="results-alltime-label" for="results-alltime" title="3">3</label>

            <input id="results-month" type="radio" name="results-tabs">
            <label id="results-month-label" for="results-month" title="2">2</label>

            <input id="results-day" type="radio" name="results-tabs">
            <label id="results-day-label" for="results-day" title="1">1</label>

How to find out in js which one the user clicked on??

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dark Hole, 2017-03-08
@artshelom

Depending on how to set the task: if it is important for you to know which user clicked on, then listen to the click event, and if which user selected, then

Array.from(document.getElementsByName('results-tabs')).filter(function(e) { return e.checked })[0];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question