[jQuery] :eq() expects number problem
I'm selecting an item based on using an index.
:eq(3) works but if I pass a variable it does not.
CODE SNIPPET:
function populateSelect(choosenValue) {
// Get the optgroup options
var choosenOptions = $('#courses optgroup:eq(choosenValue)
option');
....
THE FOLLOWING WORKS:
$('#courses optgroup:eq(3) option');
DO NOT SEEM TO WORK:
$('#courses optgroup:eq("+choosenValue+") option'); // and I don't
understand this anyhow
or
choosenValue = parseInt(choosenValue);
$('#courses optgroup:eq(choosenValue) option');
or
choosenValue = Number(choosenValue);
$('#courses optgroup:eq(choosenValue) option');
I'd appreciate a pointer here. I can see :eq expects a number and I'm
struggling to deleiver it.
Thanks