我想这很简单,而且是某种范围界定问题——但我被困住了。在下面的代码中,我希望看到带有“foo!”的警报。或“酒吧!” 当我将鼠标悬停在 div 上时。相反,我看到了空内容。如何从我有 alert() 的位置处理与选择器匹配的当前元素?TIA。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test Case</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
<!-- Tooltip classes -->
<link rel="stylesheet" href="../src/tip-yellow/tip-yellow.css" type="text/css" />
<!-- jQuery and the Poshy Tip plugin files -->
<script type="text/javascript" src="includes/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../src/jquery.poshytip.js"></script>
<script type="text/javascript">
//<![CDATA[
$(function(){
$("span[name='entity']").poshytip({
className: 'tip-yellow',
content: function(updateCallback) {
var title = $(this).attr('title');
alert(title);
updateCallback(title);
},
showTimeout: 1,
alignTo: 'target',
alignX: 'center',
offsetY: 5,
allowTipHover: true
});
});
//
//]]>
</script>
</head>
<body>
<p><span name="entity" title="foo!">Hover for a tooltip 1</span></p>
<p><span name="entity" title="bar!">Hover for a tooltip 2</span></p>
</body>
</html>