Nth-child Selector With Prototype
I'm trying to use 'nth-child(n)' with Prototype, as I do with jQuery. A code example is below... function myFunction() { $$('div.amfinder-horizontal td:nth-child(1) select').simula
Solution 1:
$$()
is the CSS selector method which returns an array of elements
$$('div.amfinder-horizontal td:nth-child(1) select').simulate('click');
will not work because you can't run simulate on an array
this should work though as long as you have Event.simulate loaded
$$('div.amfinder-horizontal td:nth-child(1) select').invoke('simulate','click');
Solution 2:
You have used $
2 times.
Probably, it is cause of your problem.
Change
$$('div.amfinder-horizontal td:nth-child(1) select').simulate('click');
$$('div.amfinder-horizontal td:nth-child(1) select').simulate('change');
to
$('div.amfinder-horizontal td:nth-child(1) select').simulate('click');
$('div.amfinder-horizontal td:nth-child(1) select').simulate('change');
Solution 3:
You can select them as in a array style
http://jsbin.com/eDAWaji/1/edit
html:
<olclass="myclass"><li>lista</li><li>lista</li><li>lista</li><li>lista</li><li>lista</li></ol>
js:
var li = $$('body > ol.myclass li');
li[3].style.background = 'red';
Post a Comment for "Nth-child Selector With Prototype"