Javascript: retrieving contents of label present in li -


i newbie javascript , not getting solution following problem code :

<ul>     <li>         <label name = "mv"> movie1 </label>         <label name = "sn"> song1 </label>         <label name = "ac"> actor1 </label>     </li>     <li>         <label name = "mv"> movie2 </label>         <label name = "sn"> song2 </label>         <label name = "ac"> actor2 </label>     </li> </ul> 

i want retrieve movie1 song1 , actor1 in first iteration , same way next. please help. thanks

working demo

a=document.getelementsbytagname("ul"); console.log(a[0].childnodes[1].innertext); 

this give want. if want second list use following

console.log(a[0].childnodes[3].innertext); 

edit: somehow firefox not take .innertext attribute. alternative use

.textcontent

cross browser compatible. tested in ie,chrome, ff

fiddle


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -