Monday, July 16, 2012

How to read html objects after rendering

This is how to read html objects after rendering: var elements = $('.item-class'); The .item-class is a css class inside a div. After that, we can now use: for (var i = 0; i < elements .length; i++) { var it = document.getElementById("id_" + i).innerHTML.split(' - ')[1].replace('%', ''); } This is getting the HTML data of all the objects inside the page with item-class css. Then, I used Split to separate the Label from the Percent, then replace the percent symbol to get the number inside. Hope you understood what I explained. Keep fighting!

No comments: