I want select all the elements with the id named singleFeed1 to singleFeed10;
for (var i=0;i<10;i++){
var post=document.getElementById('singleFeed'+i);
post.style.color='blue';
if (i==4){
post.style.color='red';
}
}
It doesn't seem to work.
my html
<li id=singleFeed1>aaaaaaaaaaaa</li>
<li id=singleFeed2>vvvvvvvvvvvv</li>
<li id=singleFeed3>dddddddddddd</li>
<li id=singleFeed4>aqqqqqqqqq</li>
<li id=singleFeed5>aaaaaddddaa</li>
......
......
Anyone has better solutions? Thanks.
if (i=4)should actually beif (i === 4)