Ok I have a list of featured paintings to show on the Index. I am displaying them using a while loop to get the details from the database.
I want to create a jQuery effect for when the user hovers over the image, the div of that picture appears.
The problem is is that if i were to hover on the first one, the first one's div is ok, but if i were to hover and leave the second one, it would affect the first one. Code below:
Script
<script>
$(document).ready(function(){
$("#featuredImage img").hover(function(){
$("#details").fadeOut();
});
});
</script>
PHP While
<ul id="featured">
<?php
$result = mysqli_query($con,"SELECT * FROM paintings WHERE featured=1");
while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
$name = $row['name'];
$desc = $row['longDesc'];
$cost = $row['cost'];
$qty = $row['quantity'];
$img = $row['imageFilename'];
$type = $row['type'];
echo "
<li id='featuredImage'>
<div id='featuredImage'><div id='details'>$name</div><img src='/$img'></div>
</li>";
}
?>
</ul>
ids are unique across the whole document; 2. you don't need js for that, CSS is enough.