I want to create an object to store jQuery objects.
Here is my code so far:
var tabList = $();
function addTab(){
console.log($(this));
var theConcept = 'conceptName';
var $tab = $('<li />');
$tab.append('<a>' + theConcept + '</a>').data("concept", theConcept);
$tab.append('<span class="closeTab">Close</span>');
console.log($tab);
tabList.push($tab);
console.log(tabList);
}
When I log the tabList, it outputs: [>e.fn.e.i]
What I’m really trying to do have an array or object that I can add and remove elements from and then refresh the DOM based on this array.
Use
.add()to add elements to a jQuery object.tabList = tabList.add($tab);