Forum Moderators: open
I am using Dojo, and am just experimenting.
I am having a problem using the indexOf method on a dojo.query nodelist.
Basically I have 5 list items in an unordered list.
I created a node list of all the li elements. (treating it like an array)
>>> var elementlist = dojo.query("li");
This displays all the elements in the node list
>>> console.log(elementlist);
[li, li#current, li, li, li]
Here I create a variable named index to use the dojo array method of indexOf to search the array 'elementlist' for the first time it sees "li#current".
>>> var index = dojo.indexOf(elementlist, "li#current");
If a match is not found the index = -1. If a match is found it should give me an index of 1 in this case...but it always seems to return -1. Either I am wrong in concept or syntax?
>>> console.log(index);
-1
Can anyone assist?
Thanks in advance.
I still would appreciate any input.
Thanks
So it makes sense that when I searched for the object reference that it was found whereas when searching for the string it was not. I guess all I would have to do is then search for the id or whatever property I wanted to find using the filter or do a forEach with a custom function doing what I want to.
Thanks