Q:

How to get class from "li" like for 

How do you get the class from a li when its inside multiple elements like this?
var ChooseAltType = $("<div>").appendTo(field_firstchild);

$('<div id="chooseCustomFields'
  + field_id
  + '" class="wrapper-customfields" tabindex="1"><span>Choose Type</span>'
  + '<ul id="chooseCustomField'
  + field_id
  + '" class="dropdown">'
  + '<li class="chooseCheckbox"><i class="fa-icon-check"></i>Checkbox</li>'
  + '<li class="chooseAlternatives"><i class="fa-icon-list-ul"></i> Alternatives</li>'
  + '<li class="chooseDropdown"><i class="fa-icon-list-alt"></i> Dropdown</li>'
  + '<li class="chooseTextField"><i class="fa-icon-font"></i> Text</li>'
  + '</ul></div>').appendTo(field_secondchild).addClass("metro three-d")
.click(function() {
    alert($('#chooseCustomFields' + field_id + ' ul #chooseCustomField'
            + field_id + ' li').prevAll().length);
});

It's just a piece of code, but I hope it's enough!

A:

Try
var ChooseAltType = $("<div>").appendTo(field_firstchild);

$('<div id="chooseCustomFields'
  + field_id
  + '" class="wrapper-customfields" tabindex="1"><span>Choose Type</span>'
  + '<ul id="chooseCustomField'
  + field_id
  + '" class="dropdown">'
  + '<li class="chooseCheckbox"><i class="fa-icon-check"></i>Checkbox</li>'
  + '<li class="chooseAlternatives"><i class="fa-icon-list-ul"></i> Alternatives</li>'
  + '<li class="chooseDropdown"><i class="fa-icon-list-alt"></i> Dropdown</li>'
  + '<li class="chooseTextField"><i class="fa-icon-font"></i> Text</li>'
  + '</ul></div>').appendTo(field_secondchild).addClass("metro three-d")
.click(function() {
    $('#chooseCustomField' + field_id + ' li').each(function() {
        console.log($(this).attr('classs'))
    });
});

