I am not sure if (1) is a big deal since they are treated as strings. it
shouldn't matter. (2) is the issue. Maybe use 'class' instead of 'id'?
then you could do something:
$('list1').getElement('.title').get('html');
notice the .get() instead of innerHTML. more of the moo way of doing things.
Welcome!
2009/4/13 Fábio Costa <[email protected]>
> 1 - You should not use id="title" or any other attribute name;
> 2 - You should not use the same id on more than one element (id=identifier,
> i.e. sould be unique).
>
>
>
> Fábio Miranda Costa
> Engenheiro de Computação
> http://meiocodigo.com
>
>
>
> On Mon, Apr 13, 2009 at 8:45 PM, Mike <[email protected]> wrote:
>
>>
>> When I try to select an element by id (where there > 1 elements with
>> the same id on the page) from within a specific element, I get the
>> following error message:
>>
>> secondListNode.getElementById("title") is null
>>
>> Should this be an error?
>>
>> It would be handy if this worked, because then I wouldn't have to use
>> selectors.
>>
>> p.s. I love MooTools. Well done. Up until recently, I was a software
>> engineer at Google. I miss all their tools, but MooTools gets me 95%
>> of the way there. It's a high quality framework.
>>
>> <ul>
>> <li id="list1">
>> <div id="title">Title 1</div>
>> <div id="content">Content 1</div>
>> </li>
>> <li id="list2">
>> <div id="title">Title 2</div>
>> <div id="content">Content 2</div>
>> </li>
>> </ul>
>>
>> <script type="text/javascript">
>>
>> var firstListNode = $("list1");
>> var firstListTitle = firstListNode.getElementById("title").innerHTML;
>> alert("First List Title: " + firstListTitle);
>>
>> var secondListNode = $("list2");
>> var secondListTitle = secondListNode.getElementById
>> ("title").innerHTML;
>> alert("Second List Title: " + secondListTitle);
>>
>> </script>
>
>
>