Im trying to use jQuery to add a different class for each Span element, using .next() This is the javascript:
<script type="text/javascript">
$(function() {
$("a", "div.top_menu").addClass("ui-icons-custom");
$("span.ui-icon:first", "ul.top_menu_list").addClass("ui-icon-pencil")
.next().addClass("ui-icon-comment")
.next().addClass("ui-icon-key");
});
</script>
And this is the HTML Im trying to make it work:
<div class="top_menu ui-state-default-custom">
<ul class="ui-widget top_menu_list">
<li>
<span style="float: left;" class="ui-icon-text-custom"><span style="float: left;" class="ui-icon"></span>
<a href="test">Registrarse</a>
</span>
</li>
<li>
<span style="float: left;" class="ui-icon-text-custom"><span style="float: left;" class="ui-icon"></span>
<a href="test1">Agregar un anuncio</a>
</span>
</li>
<li>
<span style="float: left;" class="ui-icon-text-custom"><span style="float: left;" class="ui-icon"></span>
<a href="test2">Ingresar (Login)</a>
</span>
</li>
</ul>
</div>
So it should take the first 'span' element with .ui-icon class and add a class, then the next from the list and add other class.