I have a ul menu from which I want to retrieve certain information:
<ul id="form_builder_sortable" class="sortable rightDiv session1">
<li class="draggable ui-state-highlight item id10" name="Maths">Maths<button onclick="deleteElement(event)" class="delbtn">×</button></li>
</ul>
I have a function in javascript:
function getSessionDatas()
{
var sessions = [];
$('.rightDiv').each(function(index)
{
var session = $.trim($(this).text().slice(0, -1)).split("×");
var sessionData = [];
for (var i = 0; i < session.length; i++)
{
var s = {
subjectOrder: i,
subjectID: subs[session[i]]
};
sessionData.push(s);
}
var ses = {
sessionNo: index,
sessionData: sessionData
};
sessions.push(ses);
});
}
Here:
var s = {subjectOrder:i, subjectID:<get id here>};
I want to assign the subject id according to the class of the <li> item, in this case in the class there is an id10. How can I assign the subjectID to 10 in this case?
liin eachrightDiv? Which id value will be assigned in that case?