0

我在 jsp 中使用 jQuery 1.8.2、jQuery ui 1.9.1、Firefox 16.0.1,我试图获得一个按钮来显示一个图标。我尝试的是:

$('button').button({ icons: {primary: "ui-icon-triangle-1-s" } });

在 div 中:

<div id="buttonDiv" style="text-align: center;"> <button class="btn-primary"  type="button" id="confirmationButton" value="confirm">Confirmation</button> </div>

然后我尝试使用一个 id、一个类、将类型设置为按钮等...,但由于某种原因它没有显示。

我知道,如果我尝试将按钮设为输入按钮,那么设计和使用时将无法正常工作

$('button').button() 等等..作为选择器它工作正常。

这是我的 CDN 声明:

<!-- Reference the theme's stylesheet on the Google CDN -->
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>

    <!-- Reference jQuery and jQuery UI from the CDN. Remember that the order of these two elements is important -->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>

我在这里想念什么?

4

1 回答 1

1

你确定你没有错过任何其他资源吗?您是否包含了所需的 CSS 和图像?

具体 jquery-ui.css : http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.csshttp://code.jquery.com/ui/1.9.1/themes /base/images/ui-icons_222222_256x240.png

编辑:

使用您的脚本标签,我很快就写了下来,它可以工作。

<!doctype html>
    <html>
    <head>
        <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
        <script type="text/javascript">
        $(document).ready(function(){
            $('button').button({ icons: {primary: "ui-icon-triangle-1-s" } });
        });
        </script>
        </head>
    <body>
        <div id="buttonDiv" style="text-align: center;"> <button class="btn-primary"  type="button" id="confirmationButton" value="confirm">Confirmation</button> </div>
    </body>
    </html>
于 2012-11-09T15:37:44.677 回答