Say there is a table; I want to get the values in the third column of that table and alphabetize them. I couldn’t figure out how to pull information from html tags and alphabetize the text within, because I think it was alphabetizing the elements (all of which were the same).
Anyway, here’s an example of my problem. As you can see, I can get an alphabetized list from using alert(), but not with document.write() or jQuery’s append(). Also notice that I can write a specific element from the array.
Why is this, and how can I resolve this issue?
Here’s the code: http://jsfiddle.net/bozdoz/kd4R7/
Just use .toString like this:
in your code and it works.
lettersis an array and it needs to be converted to string before append can be done. Or in a better way, usehtmlinstead ofappendlike this:This will replace the contents of
.hereinstead of appending.