I'm rewriting my own js library to jquery functions. A huge
undertaking, but hopefully worth it in the future :) Question: why
does the script always return 0 for img_width? Logo.gif exists and
moving the code to the end of the page (before the closing body-tag)
doesn't help either. Any help would be greatly appreciated!
----
My apologies is this message appears twice now. After 15 mins my first
post still did not appear in the list, so I image something went
wrong...
----
<html>
<head>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
<script>
$(document).ready(function(){
$("img.caption").each(function(i) {
var img_width = $(this).width();
var img_title = $(this).attr('title');
var img_align = $(this).attr('align');
$(this).wrap("<div class=\"image-caption-container\" style=
\"float:" + img_align + "\"></div>");
$(this).parent().width(img_width);
$(this).parent().append("<div class=\"image-caption\">" +
img_title + "</div>");
});
});
</script>
</head>
<body>
<img src="logo.gif" class="caption" title="scripting like a
rockstar">
</body>
</html>