Go Back   Dreamweaver Club Forums > Hand Coders Forum > Javascript and JS frameworks
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 01-26-2010, 09:11 PM   #1
Join Date: Jan 2009
Posts: 7
Default Jquery attr


I need a little help with some jQuery, I need to wrap a number of images in <a> tags and add the src and alt attributes.

The code below works correctly, it wraps each <img> tag adds the src to the <a> tag as an href, however if I try and do the alt attribute it only moves the first word. e.g. alt="Eco Pod" -> title="Eco" Pod="" is the output.

I don't have much hair, and therefore any help would be greatly received.

$(document).ready(function() {
$("#gallery img").each(function(){
$(this).wrap("<a href=" +$(this).attr('src') + " >");
$(this).css("display", "none");
$("#gallery img:first").css("display", "");

<img src="../images/awards_logos/ECO_POD_Logo_RGB.jpg" alt="Eco Pod" />
PaulF is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 05:48 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com