带图标的JQuery按钮 - 图标只在鼠标按下时显示
我有一个带有锚标签的页面,通过以下代码将其转换为JQuery UI按钮。带图标的JQuery按钮 - 图标只在鼠标按下时显示
$(document).ready(function() {
$('a.jquery-button-add').button({ icons : { primary: 'ui-icon-circle-plus' } });
});`
由于某种原因,当我按住鼠标按钮时,图标仅在按钮上可见。没有将鼠标按在按钮上,图标是不可见的。
这发生在所有浏览器中。
帮助将不胜感激:)
编辑:这是我使用来测试这个确切的代码:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="css/jquery-ui-overcast.css" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script>
<script type="text/javascript">
<!-- jQuery click buttons -->
$(document).ready(function() {
$('a.jquery-button-add').button({ icons : { primary: 'ui-icon-circle-plus' } });
$('a.jquery-button').button();
});
</script>
</head>
<body>
<a href="#" class="jquery-button-add">My nice button</a>
</body>
</html>
您必须除了标准的jQuery UI CSS东西是干扰,here's your code in a very simple test case working。
这是一个锚内的<span>
,像这样的结果:
<a class="jquery-button-add ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon" href="#" role="button" aria-disabled="false">
<span class="ui-button-icon-primary ui-icon ui-icon-circle-plus"></span>
<span class="ui-button-text"></span>
</a>
确保你没有其他样式与第一<span>
的规模干扰,display:block;
或overflow: hidden;
,这是通常什么原因导致.button()
问题。
请问您如何在jsfiddle上获得个性化名称? – RobertPitt 2010-09-21 10:52:36
@RobertPitt - 这是一个阿尔法测试阶段,用户手动创建用于测试几个位......不久将会有一个测试版,其中包括许多其他功能,包括自动创建帐户以允许所有想要执行相同操作的人:) – 2010-09-21 10:58:32
谢谢尼克:) – RobertPitt 2010-09-21 11:00:27
也许你没有正确加载按钮精灵文件。检查所有的图像文件在那里。 – 2010-09-21 10:52:04
图像肯定存在,因为当我点击按钮时,我可以看到图标出现,直到我将鼠标移开 – 2010-09-21 11:18:46