I am trying to get the parent item of an item with the below code.
(the content of the parent)
ex. the parent of "Item 1.1" would be "Item 2" in the below example.
Items:
<ul class="sortable" id="page-list">
<li><div>Item 1</div></li>
<li><div>Item 2</div>
<ul>
<li><div>Sub Item 1.1</div></li>
<li><div>Sub Item 1.2</div></li>
<li><div>Sub Item 1.3</div></li>
<li><div>Sub Item 1.4</div></li>
</ul>
</li>
</ul>
Javascript:
function saveNewList() {
//get DIV contents in order
var divContents = [];
$("ul.sortable > li div").each(function() { divContents.push($(this).text()) });
var quotedCSV = '"' + divContents.join('", "') + '"';
$("#results").text(quotedCSV);
//get DIV parents' contents in order
var divParents = [];
// something needs to go here...
var quotedCSVparents = '"' + divParents.join('", "') + '"';
$("#results2").text(quotedCSVparents);
}