Hi, I have a simple unordered list:
<ul id="slidebtn">
<li><img src="img/1.gif" /></li>
<li><img src="img/2.gif" /></li>
<li><img src="img/3.gif" /></li>
<li><img src="img/pause.gif" /></li>
</ul>
I would like to know if it is possible to determine the nth <li> element
without the use of an id attribute:
document.observe("dom:loaded", function(){
$('slidebtn').invoke('observe', 'click', function(e) {
var element = Event.element(e);
// this is where I need help
// if element is first <li>, alert('0');
// if element is second <li>, alert('1');
// if element is third <li>, alert('2');
// if element is fourth <li>, alert('3');
});
};
Currently, I am doing this to return the src attribute value:
document.observe("dom:loaded", function(){
$('slidebtn').invoke('observe', 'click', function(e) {
var element = Event.element(e);
// this will give me the src attribute value of the <img> element
alert(element.src);
});
};
The reason I want to return the nth index of the <li> element is so that I
can pass that as an argument to a function.
Any help in the right direction will be much appreciated.
- Paul K
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---