Reputation: 87
I have the following code:
$('#select_albums').load(document.location.href + "&action=get_albums");
But this is only replacing only the first found div with the id #select_albums from DOM. How do I replace all divs with an id?
Upvotes: 1
Views: 193
Reputation: 1326
id's must be unique, try using a class instead such as $(".albums").load...
Upvotes: 1
Reputation: 44205
Yes because by definition an element ID can only appear once on a page. If you have more elements use a class instead.
$('.select_albums').load(document.location.href + "&action=get_albums");
With
<div class="select_albums"></div>
<div class="select_albums"></div>
Upvotes: 1
Reputation: 104168
Every item in the DOM has a unique id. If you want to act on many divs at the same time use a class $(".myclass")
or a tag $("div")
selector.
Upvotes: 5