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

181
Views
Short hand for jquery selector ":checked" applied on a list

I have a list of jquery radio buttons :

<input type="radio" class="editorInput" name="radioEditor" value="1" id="radio_1">
<input type="radio" class="editorInput" name="radioEditor" value="2" id="radio_2">
<input type="radio" class="editorInput" name="radioEditor" value="3" id="radio_3">
<input type="radio" class="editorInput" name="radioEditor" value="4" id="radio_4">

I need to find the one that is checked, and get its value (or text).

For value I know I can do :

var val = $(".editorInput:checked").val();

But in some other cases, in my script I have an already build list containing these controls, for example selected by

var list = $(".editorInput");

The only way I know to get the checked one in this list requires to write an each iterator :

$(list).each(function ()
{
    if ($(this).is(":checked"))
    {
        val = $(this).val();
    }
});

My question is : is there a shorter jquery syntax to get the "checked" radio button from a list of controls (like above) containing several controls, in a single line ?

Thank you

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can modify jQuery objects, for example one way to do it is [filter() Method][1]

Another honorably mentions should go to find() Method

$list.filter(':checked') filters out checked elements.

$ulList.find('li') finds all <li> elements inside the list.

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!