Hans Pede Hans Pede - 4 months ago 18
Javascript Question

Target Paragraph Inside Table

I feel a bit stupid, I looked stackoverflow over and over again, found much help but nothing worked. I can not target the following html:

<table>
<tr>
<td>
<p class="dialog">More Infos</p>
</td>
</tr>
</table>


so that my hover effect works. I tried so many combinations, this is one of them:

$(document).ready(function()
{
$('table tr td .dialog').contenthover({
overlay_background:'#000',
overlay_opacity:0.8
});
});


I also tried to use the .find function.
The hover effect works if I just target p.dialog and remove the table structure in the html, but I need the table !

Answer

There is three things that I see.

1- A non-jQuery method : .contenthover
2- Some non-CSS attributes : overlay_...
3- CSS changes are done with .css() method.

Try this:

$('table tr td .dialog').on("mouseover",function(){
    $(this).css({"background":"#000","opacity":0.8});
});

Should work.

Comments