I try to to get text of number elements and put into array with jquery.but get this error that :
Uncaught TypeError: aTags[i].parent is not a function.
How to solve this?
$('#flight-stops-filter ul li a').click(function() {
var aTags=$('#flight-stops-filter ul li a');
stops = [];
for (var i = 0; i < aTags.length; i++) {
if (aTags[i].parent("li").hasClass('active')) {
alert(this.text);
stops.push(this.text.substr(0, 1));
}
}
});
aTags[i]is DOM element wrap it with jquery wrapper..instead ofaTags[i].parent(..use$(aTags[i]).parent(..DOMnotjQwrapped element..use$(aTags[i])var aTags=$('#flight-stops-filter ul li');and then in loop,$(this)