Reputation: 2663
I was trying to create a table which have several links which appear onHover and hides again onleave. I implemented these 2 functions
<script type="text/javascript">
function hide(cls, no) {
var select = '.' + cls + no;
$(select).hide();
}
function show(cls, no) {
var select = '.' + cls + no;
$(select).show();
}
</script>
and my HTML Code is
<tr onmouseenter="show('inv', 1)" onmouseleave="hide('inv', 1)" >
<td width="30%">
<a class="single_image" href="img/img1-big.png"><span class="icon-picture"></span> Image1.jpg</a>
</td>
<td width="40%" align="center">
<div class="button-col">
<a href="#" class="inline-buttons inv1"><span class="icon-pencil"></span> Rename </a>
<a href="#" class="inline-buttons inv1"><span class="icon-arrow-down"></span> Download </a>
<a href="#" class="inline-buttons inv1"><span class="icon-share"></span> Share </a>
<a href="#" class="inline-buttons inv1"><span class="icon-trash"></span> Delete </a>
</div>
</td>
</tr>
I am Using Bootstrap framework. This code works perfectly on IE9 and Firefox
Upvotes: 0
Views: 909
Reputation: 108500
The mouseenter
and mouseleave
events is not available in chrome (and other browsers). You should use a javascript framework that normalizes this, like jQuery.
Using jQuery, try something like:
<tr data-no="1" data-cls="inv">
And:
$(function() {
$('tr').each(function() {
var $target = $('.' + $(this).data('cls') + $(this).data('no'));
$(this).hover(
function() { $target.show(); },
function() { $target.hide(); }
);
});
});
More info on .hover()
: http://api.jquery.com/hover/
More information about compat here: https://developer.mozilla.org/en-US/docs/DOM/DOM_event_reference/mouseenter#Browser_compatibility
Upvotes: 2