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
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
Comments
Post a Comment