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!
<html>
<head>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
<script>
$(document).rea dy(function(){
$("img.caption" ).each(function (i) {
var img_width = $(this).width() ;
var img_title = $(this).attr('t itle');
var img_align = $(this).attr('a lign');
$(this).wrap("< div class=\"image-caption-container\"
style=\"float:" + img_align + "\"></div>");
$(this).parent( ).width(img_wid th);
$(this).parent( ).append("<div class=\"image-caption\">" +
img_title + "</div>");
});
});
</script>
</head>
<body>
<img src="logo.gif" class="caption" title="scriptin g like a rockstar">
</body>
</html>
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!
<html>
<head>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
<script>
$(document).rea dy(function(){
$("img.caption" ).each(function (i) {
var img_width = $(this).width() ;
var img_title = $(this).attr('t itle');
var img_align = $(this).attr('a lign');
$(this).wrap("< div class=\"image-caption-container\"
style=\"float:" + img_align + "\"></div>");
$(this).parent( ).width(img_wid th);
$(this).parent( ).append("<div class=\"image-caption\">" +
img_title + "</div>");
});
});
</script>
</head>
<body>
<img src="logo.gif" class="caption" title="scriptin g like a rockstar">
</body>
</html>
Comment