I’m using the following code on a parsed XML array:
$(this).find("cp_group").each(function() {
$("select#comp_1").append('<optgroup label="' + $(this).attr('label') + '"><option>' + $(this).find("cmp").map(function() {
return $(this).text();
}).get().join("</option><option>") + $(this).append('</option></optgroup>'));
});
And i get an unwanted [object Object] in the last option of each option group as following:
<select name="comp_1" id="comp_1">
<optgroup label="Combat">
<option>Arme</option>
<option>Arts martiaux</option>
<option>Esquive</option>
<option>Feinte</option>
<option>Parade</option>
<option>Lutte[object Object]</option>
I dont understand from where this [object Object] come from and I didn’t achieve to not get it or to remove it.
Thanks for you help.
It’s coming from the
+ $(this).append(...). You just want the+'</option....'part, without that jQuery wrapper.