皮肤脚本适用于小提琴,但不适用于生活

时间:2012-07-18 03:51:43

标签: jquery

以下是指向working fiddle的链接,此处是live page无法使用的链接。

点击“点击”后,应检查域是否有值,如果不是,则将div打扮成错误框。 “点击”将成为一个按钮,并且会有一个输入文本框,但由于没有域,结果应该只是打开对话框。适用于小提琴而非实时代码:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.21/themes/base/jquery-ui.css" type="text/css" media="all" />

<div onclick="check_domain_input()">Click</div>

<div id="dialog" title="Attention!" style="display:none">
    Please enter a domain name to search for.
</div>

<script>
    function check_domain_input()
    {        
        $( "#dialog" ).dialog(); // Shows the new alert box.

        var domain_val = document.getElementsByName('domain');

        if (domain_val[0].value.length > 0)
        {
            return true;
        }

        $( "#dialog" ).dialog();

        return false;
    }
</script>

1 个答案:

答案 0 :(得分:4)

默认情况下,jQuery没有附带jQueryUI。 包括它。

http://www.jqueryui.com

编辑:下面的评论意味着混乱。

在你的jsFiddle中,在左侧面板的jQuery库选择下面,你勾选了'jquery ui'。 这是另一个javascript库,jQuery的扩展。您可以通过以上链接下载。

它有默认的UI-skinning,这是你已经包含的CSS文件。

您还需要包含jQueryUI脚本BELOW / AFTER jQuery。

编辑:只需在<script src="js/jquery.js"></script>

之后添加此行

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>