Show hide class on hover using jQuery

Something like this works for me:

<script>
    $(document).ready(function() {
        $(".container").hover(
            function() { $(this).children('.comment_actions').show(); },
            function() { $(this).children('.comment_actions').hide(); }
        );
    });

</script>

<style>
</style>

<table border="1">
    <tr>
        <td class ="container"><br/>
            asd<span class="comment_actions">Approve | Delete</span>
        </td>
        <td class ="container"><br/>
            asd <span class="comment_actions">Approve | Delete</span>
        </td>
        <td class ="container"><br/>
            asd<span class="comment_actions"> Approve| Delete</span>
        </td>
    </tr>
</table>

However, the issue you'll face is hover actions over a div that has display: none; set. You might want to consider wrapping it in something that's mouse sensitive, and then displaying/hiding children instead.


If I'm reading that correctly, the format should be-

$(".comment_div").hover(
  function() { $(this).children(".comment_actions").show(); },
  function() { $(this).children(".comment_actions").hide(); }
);