我有一个 each 方法,我正在利用它来启动一个<td>
与其存在的相关的工具提示。在 IE、Chrome、Safari 中一切都很好,但 Firefox 完全缺少 each 方法,并且只启动 DOM 中的最后一个工具提示。
是什么赋予了?
HTML:
<div class="stage">
<div class="dealFinder">
<h2 class="title">Deal Finder in Your Area</h2>
<table cellpadding="5">
<tr>
<td class="text">
<p class="makeModel"><a href="#">2012 Land Rover Range Rover Evoque</a><br>in Oak Lawn</p>
<a class="youSave" href="#" onclick="return false"> You Save at Least $14,810</a>
<div class="tooltip">
<div class="inner">
<b>2012 Land Rover Range Rover Evoque</b>
<span>Your Price $19,330</span>
<p>The National Average is <b>$21,500</b></p>
</div>
</div>
</td>
<td class="pic">
<a href="#"><img src="http://placehold.it/113x75" /></a>
</td>
</tr>
<tr>
<td class="text">
<p class="makeModel"><a href="#">2012 Land Rover Range Rover Evoque</a><br>in Oak Lawn</p>
<a class="youSave" href="#" onclick="return false"> You Save at Least $14,810</a>
<div class="tooltip">
<div class="inner">
<b>2012 Land Rover Range Rover Evoque</b>
<span><small>Your Price</small> $19,330</span>
<p>The National Average is <b>$21,500</b></p>
</div>
</div>
</td>
<td class="pic">
<a href="#"><img src="http://placehold.it/113x75" /></a>
</td>
</tr>
</table>
</div><!-- .dealFinder -->
</div>
jQuery:
$(document).ready(function() {
// Tooltip
$('.tooltip').hide();
$('.text').each(function(e) {
var self = this;
var tooltip = $(self).find('.tooltip');
var youSave = $(self).find('.youSave');
$(youSave).mouseenter(function(e) {
$(self).find(tooltip).fadeIn("slow");
});
$(youSave).mouseleave(function(e) {
$(self).find(tooltip).fadeOut("fast");
});
});
});