The string "#aller" is called a selector - meaning it selects elements from the DOM. Whilst the ID (#) selector will only ever return at most 1 element, other selectors can return more than 1, for example:
$(".my_class")
will return all elements with a CSS class of "my_class". The returned object is a jQuery object, which contains, amongst other things (such as functions) the DOM elements found. The DOM elements are accessible individually via array element access with integer index, so $("#aller")[0] will give you the first DOM element found with ID of "aller". --rob On 7/2/07, debussy007 <[EMAIL PROTECTED]> wrote:
I have everything working now, thank u very much for your kind help. Though I do not understand the array $("#aller")[0] what are in the next indexes $("#aller")[1], $("#aller")[2], ... ? Rob Desbois-2 wrote: > > Hi, the syntax you need for selecting by ID is this: > >> $("#identifier") >> > so to find the element with ID 'aller' you want: > >> $("#aller") > > > > Bear in mind that the $() function does not return a DOM object, it > returns > a jQuery object. > If you want to access a DOM property such as selectedIndex, you will need > to > retrieve the DOM object like this: > >> alert($("#aller")[0].selectedIndex); >> > > Remember also that that line will generate an error if there is no element > found with ID 'aller'. > > I hope that explains it for you :-) > --rob > > > On 7/2/07, debussy007 <[EMAIL PROTECTED]> wrote: >> >> >> >> Hi, >> >> I am trying to access my SELECT element with jQuery but I can't make it >> working : >> >> This works : >> alert(document.getElementById('aller')); // >> [object] >> var sel = document.getElementById('aller'); >> alert(sel.selectedIndex); // 0 >> This not working : >> alert($(document.aller)); // [object Object] >> alert($(document.aller).selectedIndex); // undefined >> >> Could anyone help me ? >> >> Thank u for any comment. >> >> >> -- >> View this message in context: >> http://www.nabble.com/%24%28elem%29--question-tf4011702s15494.html#a11392465 >> Sent from the JQuery mailing list archive at Nabble.com. >> >> > > > -- > Rob Desbois > Eml: [EMAIL PROTECTED] > Tel: 01452 760631 > Mob: 07946 705987 > "There's a whale there's a whale there's a whale fish" he cried, and the > whale was in full view. > ...Then ooh welcome. Ahhh. Ooh mug welcome. > > -- View this message in context: http://www.nabble.com/%24%28elem%29--question-tf4011702s15494.html#a11393227 Sent from the JQuery mailing list archive at Nabble.com.
-- Rob Desbois Eml: [EMAIL PROTECTED] Tel: 01452 760631 Mob: 07946 705987 "There's a whale there's a whale there's a whale fish" he cried, and the whale was in full view. ...Then ooh welcome. Ahhh. Ooh mug welcome.