javascript - Assign ID's to dynamically generated elements using jquery -
in application read rss feed. using zrssfeed (http://www.zazar.net/developers/jquery/zrssfeed/) elements of feed displayed. problem inside each list item, there 3
elements without id or class.
i want style each of these
elements differently. how can achieve this?
<div> <ul> <li> <img /> <p>text1</p> <p>text2</p> <p>text3</p> </li> <li> .. next item... </li> </ul> </div>
how can achieve assigning different id each of these elements?
// after elements have been created $('li').find('p').each(function (i) { $(this).attr('id', 'p_' + i); });
you use css3's nth-child
selectors:
p:nth-child(1) { color: pink; } p:nth-child(2) { color: green; } p:nth-child(3) { color: yellow; }
Comments
Post a Comment