使用jQuery-ui預覽圖片

1、官網下載地址:http://jqueryui.com/download/

2、引入文件,本地環境是laravel:

<link rel="stylesheet" href="{{ '/public/jquery-ui/jquery-ui.min.css' }}">
<script type="text/javascript" src="{{ '/public/jquery-ui/jquery-ui.min.js' }}"></script>
3、有一個容器,用來放圖片:

<div id="showDetail" style="display:none"><img src="" id="showImg" alt=""></div>
4、函數處理:

function showImg(name, path)
        {
            $('#showImg').attr("src", path);
            $('#showDetail').dialog({
                height: 'auto',
                width: 'auto',
                position: {my:"center", at:"center", collision:"fit"},
                modal: false,  // 是否模式對話框
                draggable: true,   // 是否允許拖拽
                resizable: true,   // 是否允許拖動
                title: name,   // 對話框標題
                show: "slide",
                hide: "explode"
            });
        }
5、效果




發佈了75 篇原創文章 · 獲贊 35 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章