I had image elements coming from a for loop, and an X in the upper right hand corner that deletes them from the DB.
I decided to make it so that clicking the image would delete it instead. After that, I lost the X altogether, but it occured to me that it might be a better user experience if the X showed back up onmousover to indicate that the image would be deleted (still not sure if I'm going with opacity 0 -> opacity 1 or white -> red).
So here's my image:
<div class="close"><i id="<?php echo $images[$i]->id; ?>" class="fas fa-times"></i></div>
<img id="<?php echo $images[$i]->id; ?>" onclick="delete_img(this.id);" onmouseover="show_x(this.id)" src="https://drive.google.com/thumbnail?id=<?php echo $images[$i]->image_id; ?>&export=view&sz=w250">
And my jquery
function show_x(id)
{
$("#" + id).css("color", "red");
}
Relevant CSS:
.fas
{
color: #ffffff;
}
It really feels like this should work, but it doesn't. I know I'm getting into the function, because I can write:
alert(id);
And it does exactly what I expect. I know jQuery is functioning properly, because the other jQuery function delete_img(id)
works just fine.
Any insight is appreciated. If this is a stupid question, please forgive me, because I know not what I do.
I also tried giving them different ID's..something like adding "x_" to the Font Awesome div ID, and ammending the jQuery like this:
function show_x(id)
{
$("#x_" + id).css("color", "red");
}
But that didn't work either.
Taplar, see this:
<i class="fas fa-times <?php echo $images[$i]->id; ?>" style="color: white;"></i>
and
function show_x(id)
{
$("."+id).css("color", "red");
}
Apologies for making invalid web markup, but this also doesn't seem to work.