我正在使用一个简单的 JQuery 解决方案从链接中获取 href 并将其应用于单击事件。这适用于 Webkit 和 Gecko 浏览器,但是 Internet Explorer (7 & 8) 一直将 href 位置显示为undefined。有人对此有修复吗?可以帮我解决这个问题吗?如果是这样,非常感谢。
$('table tr').click(
function () {
var element = $(this).attr("class");
var hrefLocation = $('#'+ element +' .deal-holder a').attr('href');
alert(hrefLocation)
window.location.href = hrefLocation;
return false;
}
);
HTML 很简单:
<tr class="QRG">
<td class="blue"><a href="#QRG">QRG</a></td>
<td>Company Sale</td>
<td>Technology</td>
</tr>
<div class="deal" id="QRG">
<p><span class="js">Overview</span><span class="no-js">Enham</span></p>
<div class="deal-holder">
<div class="image-holder">
<img src="../assets/images/enham.gif" alt="" height="70" width="150" />
</div>
<p>Enham is a charity established in 1918, which delivers a wide range of essential services that provide choice and empowerment to disabled people to make their own decisions about their lives. Enham is a charity established in 1918, which delivers a wide range of essential services that provide choice and empowerment to disabled people to make their own decisions about their lives</p>
<a class="moreInfo" href="individual.html">More Information</a>
</div>
</div>