Monday, July 16, 2012
single quote versus backslash double quote
In HTML code behind, we tend to use single quotes to indicate the ID of an html object. But the best practice that we need to know is to always use backslash double quote. This is being parsed by all kinds of browsers (even IE 6 or other lower versions of browsers). The single quotes are only read by new browsers so we might be confused why our code has browser compatibility issues.
Sharing is caring!
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!
Subscribe to:
Posts (Atom)