You need quotes for the attributes:

append('<img src="'+ this +'" alt="'+ altName +'" class="product" /
>');

Interesting use of the attr() function, I thought doing that would
make href="".

On Oct 29, 9:33 pm, Nathan <[EMAIL PROTECTED]> wrote:
> I'm using attr('title') to find the title of the first anchor in a
> list and then make that title the value of an alt tag for an image.
>
>         $('#imageswap a:first').attr('href', function(){
>                 var altName = $(this).attr('title');
>                 $('#productimage').append('<img src='+ this +' alt='+ altName 
> +'
> class="product" />');
>                 $('img.product').fadeIn(1000);
>         });
>
> The problem is if the anchor title has spaces (title="firstWord
> secondWord thirdWord") it gives me:
>
>         <img class="product" thirdword="" secondword="" alt="firstWord"
> src="imageName.jpg"/>
>
> Any ideas on why it's doing this? I can't figure it out.

Reply via email to