JQuery Basics - Selecting Elements Inside a Cached Element

Sorry, this is a very simple jQuery syntax question, but I can't find anyone to discuss it anywhere (perhaps because I don't know the correct search terms).

I want to select / cache using a variable, and then get the value of the verified inputs. Now I know that I can do this without caching as:

var questionID = (a string)
$(questionID + " input:radio:checked").val()

But I use the div # 'questionID' object several times, so I want to cache it i.e.

questionID = '#' + ...Something that changes ...
$question = $(questionID);

Now that $ question is a jQuery object, I cannot decide how to select things inside it (without using children ())

For example, the following do not work:

$question.(' input:radio:checked)
$($question 'input:radio:checked')

I guess this is really the basic bit of syntax, but I can't find it anywhere, and I tried many combinations with no luck ......

, , jQuery,

+5
4

var checkedRadios = $('input:radio:checked', $question);

var checkedRadios = $question.find('input:radio:checked');

, api jQuery Documentation

find .

+1

.find(), , , !

$question.find('input:radio:checked');

EDIT API jQuery, http://api.jquery.com/category/traversing/tree-traversal/

0

$('input:radio:checked', $question)...

0

,

var checkedRadiosInsideQuestion = $question.find('input:radio:checked');
0

All Articles