I can't seem to figure out how to use the $.unique(array) function in JQuery. What I am trying to do is check the XML file to see what the range of home sizes is. The result will go into a list, but if there are duplicate items, I'd like to remove these.
A subset of XML Doc
This line loops through XML and builds array "parentOption":Code:<dimensions><bed>3</bed></dimensions>
<bath>2</bath>
<area>1000</area>
Not sure if I'm using this function correctly:Code:$(xml).find("bed").each(function(xml){parentOption.push($(this).text() + " bedroom " + $(this).siblings('bath').text() + " bathroom " );});
Loop through array and display items to menu:Code:newArray = $.unique(parentOption);
Code:$.each(newArray, function(n, val){var htmlOutput = "<option id='" + val + "' value='" + val + "'> " + val + " </option>";});
$('#parentMenu').append(htmlOutput);
