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); }); 

fiddle

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; } 

fiddle


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -