jquery ui 文檔使用總結,jqueryui文檔總結

來源:互聯網
上載者:User

jquery ui 文檔使用總結,jqueryui文檔總結

介紹jquery ui文檔中的api如何使用


<!doctype html>

<html lang="us">
<head>
<meta charset="utf-8">
<title>jQuery UI Example Page</title>
<link href="jquery-ui.css" rel="stylesheet">
    <style>
        #draggable { width: 150px; height: 150px; padding: 0.5em; }
        #parent{width:400px;height:400px;border: 1px solid #66afe9;}

        .toggler { width: 500px; height: 200px; position: relative; }
        #button { padding: .5em 1em; text-decoration: none; }
        #effect { width: 240px;  padding: 1em;  font-size: 1.2em; border: 1px solid #000; background: #eee; color: #333; }
        .newClass { text-indent: 40px; letter-spacing: .4em; width: 410px; height: 100px; padding: 30px; margin: 10px; font-size: 1.6em; }
    </style>

</head>
<body>

<!--draggable-->
<div id="parent">
<div id="draggable" class="ui-widget-content">
    <p>Drag me around</p>
</div>
</div>
<!--draggable-->

<!--dialog-->
<button id="opener">open the dialog</button>
<div id="dialog" title="Dialog Title">I'm a dialog</div>
<!--dialog-->

<!--effect-->
<div class="toggler">
    <div id="effect" class="ui-corner-all">
        Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede.
    </div>
</div>

<button id="button" class="ui-state-default ui-corner-all">Run Effect</button>
<!--effect-->


<script src="external/jquery/jquery.js"></script>
<script src="jquery-ui.js"></script>

<script>
    //interactions模組<draggable>
    $(function() {
        //參數的使用
        $( "#draggable" ).draggable({containment:'#parent',revert:true,revertDuration:1000});
        //參數get和set的使用
        $( "#draggable" ).draggable( "option", "axis", "y" );
        var axis = $( "#draggable" ).draggable( "option", "axis" );
        alert(axis);
        //事件的使用
        $( "#draggable" ).draggable({
            stop: function( event, ui ) {
               //方法的使用
                $( "#draggable" ).draggable( "disable" );
            }
        });

        //widgets模組options methods events
        //參數使用
        $( "#dialog" ).dialog({ autoOpen: true,buttons: [ { text: "Ok", click: function() { $( this ).dialog( "close" ); } } ]});
        $( "#opener" ).click(function() {
            //函數使用
            $( "#dialog" ).dialog( "close" );
        });
        //事件使用
        $( "#dialog" ).dialog({
            close: function( event, ui ) {
                alert("close");
            },
            //ui對象的使用,查看相應api的屬性
            drag: function(event,ui){
                alert(ui.position.left);
            }
        });

        //effect模組addClasss
        $( "#button" ).click(function() {
            //參數使用className duration easing complete
            $( "#effect" ).addClass( "newClass", 1000,'easeInCubic', callback );
        });
            //回呼函數
        function callback() {
            setTimeout(function() {
                $( "#effect" ).removeClass( "newClass" );
            }, 1500 );
        }
    });

</script>

</body>

</html>

一篇文章關於jquery ui的總結 http://wenku.baidu.com/link?url=O1p4Fjh3gvhps9ImY4HVYf2PCyU4IueD6BqxtpoStks5_I1Dwn8I4fjPc2EGk6JClx0Fv1OG6m3Gjn-Eb0XgYTVhCAQWbqNRyA0f2c1uk7O


JQuery UI檔案引用問題

要顯示所有功能,只需要引入一下檔案
<scipt type="text/javascript" src="jquery-1.4.2.min.js"></script><!-- 引入jQUery庫 -->
<scipt type="text/javascript" src="jquery-ui-1.8.11.custom.min.js"></script><!-- 引入jQUeryUI庫 -->
<link rel="stylesheet" type="text/css" href="jquery-ui-1.8.11.custom.css" /><!-- 引入jQUeryUI CSS 樣式 -->
要實現單一功能比如你說的tab功能,可以引入下面內容
<scipt type="text/javascript" src="jquery-1.4.2.min.js"></script><!-- 引入jQUery庫 -->
<scipt type="text/javascript" src="jquery.ui.core.js"></script><!-- 引入jQUeryUI 核心庫,所有功能必須引入 -->
<scipt type="text/javascript" src="jquery.ui.widget.js"></script><!-- 引入jQUeryUI Widget庫,所有功能必須引入,個別可能不需要,不過建議引入 -->
<!-- 以下引入功能類庫 -->
<scipt type="text/javascript" src="jquery.ui.tabs.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.ui.tabs.css" />
<!-- 以上是引入功能類 -->

對於EasyUI,我不建議使用。現在EasyUI功能還不是很健全。瀏覽器安全色性很差。唯一一點讓人稱道的是EasyUI的DataGrid,不過也是功能不完善。jQueryUI,功能強大,不過你要想實現好的效果,需要你自己手動修改它的css,來重構漂亮的介面!
 
jquery ui 怎使用?

主要根據你需要的效果載入不同的 CSS 和 圖片包
不過核心的 JS 檔案直接引用就可以了

前提,先引用 jQuery 庫
<script src="jquery.min.js" type="text/javascript" ></script>
再來就是 jQuery UI 外掛程式
<script src="jquery-ui.js" type="text/javascript" ></script>

之後在 DOM ready 好的環境裡使用 jquery-ui 的外掛程式
常見的有
$(target).datepicker();
$(target).tabs();

這些所用到的外掛程式都需要樣式套件 - 名為 theme,是為了自訂樣式套用到所關的 Class 或者元素,詳情見參考資料的網址
參考資料:jqueryui.com/docs/Theming/API
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.