JQuery buttons with icons - icon only shows when mouse pressed down
I have a page with anchor tags that are being converted to JQuery UI buttons via the following code.
$(document).ready(function() {
$('a.jquery-button-add').button({ icons : { primary: 'ui-icon-circle-plus' } });
});`
For some reason, the icon is only visible on the button when I hold the mouse button down. Without holding the mouse down on the button, the icon is invisible.
This is occurring in all browsers.
Help would be greatly appreciated :)
EDIT: This is the exact code I am using to test this:
<!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>
You must have something in addition to the standard jQuery UI CSS that's interfering, here's your code in a very simple test case working.
It's a <span>
within an anchor, like this that results:
<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>
Make sure that you don't have additional styles interfering with that first <span>
's size, display:block;
or overflow: hidden;
, that's usually what causes .button()
issues.
精彩评论