第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

jQuery UI-在外部單擊時關(guān)閉對話框

jQuery UI-在外部單擊時關(guān)閉對話框

喵喵時光機 2019-09-21 11:16:54
我有一個jQuery UI對話框,當(dāng)單擊特定元素時會顯示該對話框。如果單擊不是在那些觸發(fā)元素或?qū)υ捒虮旧砩系娜魏蔚胤桨l(fā)生的,我想關(guān)閉對話框。這是打開對話框的代碼:$(document).ready(function() {    var $field_hint = $('<div></div>')        .dialog({            autoOpen: false,            minHeight: 50,            resizable: false,            width: 375        });    $('.hint').click(function() {        var $hint = $(this);        $field_hint.html($hint.html());        $field_hint.dialog('option', 'position', [162, $hint.offset().top + 25]);        $field_hint.dialog('option', 'title', $hint.siblings('label').html());        $field_hint.dialog('open');    });    /*$(document).click(function() {        $field_hint.dialog('close');    });*/});如果我取消注釋的最后一部分,該對話框?qū)⒂肋h不會打開。我認(rèn)為這是因為打開對話框的同一點擊再次將其關(guān)閉。最終工作代碼注意:這是使用jQuery外部事件插件$(document).ready(function() {    // dialog element to .hint    var $field_hint = $('<div></div>')            .dialog({                autoOpen: false,                minHeight: 0,                resizable: false,                width: 376            })            .bind('clickoutside', function(e) {                $target = $(e.target);                if (!$target.filter('.hint').length                        && !$target.filter('.hintclickicon').length) {                    $field_hint.dialog('close');                }            });    // attach dialog element to .hint elements    $('.hint').click(function() {        var $hint = $(this);        $field_hint.html('<div style="max-height: 300px;">' + $hint.html() + '</div>');        $field_hint.dialog('option', 'position', [$hint.offset().left - 384, $hint.offset().top + 24 - $(document).scrollTop()]);        $field_hint.dialog('option', 'title', $hint.siblings('label').html());        $field_hint.dialog('open');    });    // trigger .hint dialog with an anchor tag referencing the form element    $('.hintclickicon').click(function(e) {        e.preventDefault();        $($(this).get(0).hash + ' .hint').trigger('click');    });});
查看完整描述

3 回答

?
素胚勾勒不出你

TA貢獻1827條經(jīng)驗 獲得超9個贊

查看jQuery Outside Events插件


讓您做:


$field_hint.bind('clickoutside',function(){

    $field_hint.dialog('close');

});


查看完整回答
反對 回復(fù) 2019-09-21
  • 3 回答
  • 0 關(guān)注
  • 628 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號