The best way (IMO) to know if they're working is to view this site in
Firefox with the Web Developers Toolbar. Under the View Source button on the
toolbar is an option for "view generated source". This will show you the
results of the page after any JavaScript has been executed. It'll display
new attributes, changed attributes, new DOM nodes, etc.


andy

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of enchance
Sent: Friday, November 28, 2008 7:52 PM
To: jQuery (English)
Subject: [jQuery] Adding IMG attributes


I'm trying to add several attributes to all my img tags but I'm not sure if
they're both working. Could you verify if these are correct?

$(document).ready(function(){
//add the width and height for each image $('img').each(function(){
   $(this).attr('width', $(this).width());
   $(this).attr('height', $(this).height()); });

//copy alt to title
$('img').attr('title', function(){
   $(this).attr('alt');
});
});

Am I doing the right thing?


Reply via email to