dniwebdesign
03-05-2011, 08:55 PM
I modified the original code just a little and now have $('#special a').bind('mouseover', function(){
$(this).parent('div').css({position:'relative'});
var img = $(this).children('img');
$('<div />').text(' ').css({
'height': img.height(),
'width': img.width(),
'background-color': 'black',
'position': 'absolute',
'background': 'url(delete.png) center no-repeat black',
'top': 0,
'left': 0,
'opacity': 0.5
}).bind('mouseout', function(){
$(this).remove();
}).insertAfter(this);
});
With my html being:<table cellpadding="10" cellspacing="0" border="0">
<tr>
<td valign='top' style='padding: 5px; margin: 0px;'>
<div id='special' align='center'>
<a href='../../iMaGeGaLlEry/Test/47143_147210328635837_100000406113729_301983_2857122_n.jpg'>
<img border='0' src='../../thumb.img.php?album=../../iMaGeGaLlEry/Test&im=47143_147210328635837_100000406113729_301983_2857122_n.jpg' class='hover'>
</a>
</div>
</td>
<td valign='top' style='padding: 5px; margin: 0px;'>
<div id='special' align='center'>
<a href='../../iMaGeGaLlEry/Test/47377_147210731969130_100000406113729_301987_7618538_n.jpg'>
<img border='0' src='../../thumb.img.php?album=../../iMaGeGaLlEry/Test&im=47377_147210731969130_100000406113729_301987_7618538_n.jpg' class='hover'>
</a>
</div>
</td>
<td valign='top' style='padding: 5px; margin: 0px;'>
<div id='special' align='center'>
<a href='../../iMaGeGaLlEry/Test/154973_591749991437_32600476_34231000_8211372_n.jpg'>
<img border='0' src='../../thumb.img.php?album=../../iMaGeGaLlEry/Test&im=154973_591749991437_32600476_34231000_8211372_n.jpg' class='hover'>
</a>
</div>
</td>
<td valign='top' style='padding: 5px; margin: 0px;'>
<div id='special' align='center'>
<a href='../../iMaGeGaLlEry/Test/being-erica-full.jpg'>
<img border='0' src='../../thumb.img.php?album=../../iMaGeGaLlEry/Test&im=being-erica-full.jpg' class='hover'>
</a>
</div>
</td>
</tr>
</table>
Now, the rollover sort of works exactly the way I want it to (I want to show a red X over top of the main image. The image is read from the directory, modified using GD to a thumbnail size and then displayed so the sizes may vary depending on the original.
However, the link disappears and I cannot click on the link. I eventually want it so I can delete the image by clicking on it. How can I get my link back YET keep the hover image?
Also, on a side note there is about 1-2 pixels at the bottom of every image that if landed on just right creates another overlay over the first overlay giving it two overlays on one image. How would I fix that as well. Thanks.
$(this).parent('div').css({position:'relative'});
var img = $(this).children('img');
$('<div />').text(' ').css({
'height': img.height(),
'width': img.width(),
'background-color': 'black',
'position': 'absolute',
'background': 'url(delete.png) center no-repeat black',
'top': 0,
'left': 0,
'opacity': 0.5
}).bind('mouseout', function(){
$(this).remove();
}).insertAfter(this);
});
With my html being:<table cellpadding="10" cellspacing="0" border="0">
<tr>
<td valign='top' style='padding: 5px; margin: 0px;'>
<div id='special' align='center'>
<a href='../../iMaGeGaLlEry/Test/47143_147210328635837_100000406113729_301983_2857122_n.jpg'>
<img border='0' src='../../thumb.img.php?album=../../iMaGeGaLlEry/Test&im=47143_147210328635837_100000406113729_301983_2857122_n.jpg' class='hover'>
</a>
</div>
</td>
<td valign='top' style='padding: 5px; margin: 0px;'>
<div id='special' align='center'>
<a href='../../iMaGeGaLlEry/Test/47377_147210731969130_100000406113729_301987_7618538_n.jpg'>
<img border='0' src='../../thumb.img.php?album=../../iMaGeGaLlEry/Test&im=47377_147210731969130_100000406113729_301987_7618538_n.jpg' class='hover'>
</a>
</div>
</td>
<td valign='top' style='padding: 5px; margin: 0px;'>
<div id='special' align='center'>
<a href='../../iMaGeGaLlEry/Test/154973_591749991437_32600476_34231000_8211372_n.jpg'>
<img border='0' src='../../thumb.img.php?album=../../iMaGeGaLlEry/Test&im=154973_591749991437_32600476_34231000_8211372_n.jpg' class='hover'>
</a>
</div>
</td>
<td valign='top' style='padding: 5px; margin: 0px;'>
<div id='special' align='center'>
<a href='../../iMaGeGaLlEry/Test/being-erica-full.jpg'>
<img border='0' src='../../thumb.img.php?album=../../iMaGeGaLlEry/Test&im=being-erica-full.jpg' class='hover'>
</a>
</div>
</td>
</tr>
</table>
Now, the rollover sort of works exactly the way I want it to (I want to show a red X over top of the main image. The image is read from the directory, modified using GD to a thumbnail size and then displayed so the sizes may vary depending on the original.
However, the link disappears and I cannot click on the link. I eventually want it so I can delete the image by clicking on it. How can I get my link back YET keep the hover image?
Also, on a side note there is about 1-2 pixels at the bottom of every image that if landed on just right creates another overlay over the first overlay giving it two overlays on one image. How would I fix that as well. Thanks.