I’ve added a bunch of links to a div like this:
$('#links').append('<a href="http://example.com/">Example</a>');
But when I try to loop through them with $('#links a').each it only finds the links that are already there in the HTML.
What am I doing wrong?
Your code as you’ve given it above works fine (tested). That means you’re doing something else that’s causing the problem. Possibilities include:
My personal guess is the last one there, since it’s the least obvious. But I’ve made all three mistakes in the past. Hope that helps.