You have to loop through the jQuery set. You can use the each() method
for that.

$(document).ready(function(){
    $(".img").each(function() {
        var url = this.href;
        $("#imgbox").append('<img src="+url+" />');
    });
});

On Aug 26, 4:06 pm, Jottae <[email protected]> wrote:
> Hi guys
> I'm trying to do the following:
>
> -----------------------------------------
> $(document).ready(function(){
>   img=$(&quot;.img&quot;);
>   imga=img.attr(&quot;href&quot;);
>   $(&quot;#imgbox&quot;).append(&quot;<img src='&quot;+imga+&quot;'/
>
> >&quot;);
> });
>
> ---------------------------------------
>
> Want to get all the images with the "img" class and the append them in
> the div "imgbox". But I can only return the first image. Does anyone
> have any suggestions? Thanks.
>
> EX:. these are the images that I want to get
> ---------------------------------------
> <a class="img" href="http://example.com/Zelda-01.jpg"; >Galeria</a>
>
> <a class="img" href="http://example.com/Zelda-02.jpg"; >Galeria</a>
> ...
> ---------------------------------------

Reply via email to