There is the following HTML structure
<div>
<p class="open">some txt</p>
<p>some text 2</p>
<p>some text 3</p>
<a href="javascript:;" onclick="down(this.parentNode)">Down</a>
</div>
and when I press down I want to move class "open" to next p tag, here is code that do this, but I didn't think that it most elegant solution
function down(el){
el.getElementsBySelector("p.open").each(
function(s){
s.removeClassName('open');
if (s.next('p')){
s.next('p').addClassName('open');
}
else{
el.getElementsBySelector("p:first").each(
function(e){
e.addClassName('open');
}
);
}
}
);
}
how this code can be improved?