I got a pretty simple code, but I bet it's really bad written.
I tried to create some objects inside an array, and then build a list using jQuery .each() method.
I think this is stupidly easy, but I'm just learning...
This is the jQuery code I've written:
$(document).ready(function () {
//items
var armas = {
BK: {
mano_izq: [{
type: 2,
index: 5,
name: "juan"
}, {
type: 2,
index: 5,
name: "juancho"
}]
},
MG: {
mano_der: [{
type: 2,
index: 5,
name: "juan2"
}, {
type: 2,
index: 5,
name: "juan3"
}]
}
};
//controles
$("#selec").on("click", function (e) {
e.preventDefault();
$(".itemlist").each(armas.BK.mano_izq, function (i, value) {
$(this).append('<li>'+ value.name +'</li>');
});
});
});
As you can see, in that example I'm trying to build this list (without success, sadly)
<ul class="itemlist">
<li>juan</li>
<li>juancho</li>
<li>juan2</li>
<li>juan3</li>
</ul>
You can check my fiddle here: http://jsfiddle.net/Frondor/xbcxy8ur/