<ul>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
<script>
$(document).ready(function(){
var page = new Array("red","green","gray");
for(i = 0; i < page.length; i++){
//alert(page[i]);
$('ul li').children('a').eq(i).html(page[i]).attr("href", page[i]).css("color",page[i]);
//$('ul').children('li').eq(i).html('<a href="#"></a>').find('a').text(page[i]).attr("href", page[i]).css("color",page[i]);/*********If a tag is not present in list**********/
}
});
</script>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
<script>
$(document).ready(function(){
var page = new Array("red","green","gray");
for(i = 0; i < page.length; i++){
//alert(page[i]);
$('ul li').children('a').eq(i).html(page[i]).attr("href", page[i]).css("color",page[i]);
//$('ul').children('li').eq(i).html('<a href="#"></a>').find('a').text(page[i]).attr("href", page[i]).css("color",page[i]);/*********If a tag is not present in list**********/
}
});
</script>
No comments:
Post a Comment