rob.m rob.m - 1 year ago 129
jQuery Question

Uncaught TypeError: $thirdColumnCells.each is not a function

I am running this but I have the console keeps giving me the error in the question title. basically I am reading the

value from a link and I am pushing it into a


<div id="link"><ul></ul></div>


var $thirdColumnCells = $hiddenContentB.find('table.wikitable tr').find('td:nth-child(3) a').attr("href");

$thirdColumnCells.each(function(idx, cell) {
var valB = $(cell).text().match(/\d+/)[0];
$('#link').append('<li>'+ valB + '</li>');

Answer Source

jQuery's .attr() returns a string.

jQuery's .each() iterates over objects and arrays, usually array-like objects holding elements

What you're doing is

var $thirdColumnCells = $(element).attr("href");

$thirdColumnCells.each(... // <- that's a string !!!
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download