views:

38

answers:

4

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?

+5  A: 

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.

kgiannakakis
It works! Thanks a lot. It actually makes sense
Dudul
+1  A: 

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>
Daff
+1  A: 

id's must be unique, try using a class instead such as $(".albums").load...

Alistair
+1  A: 

ids must be unique

Eric