Closing a modal by clicking outside of the modal

I have a modal window build with CSS. The modal can be closed by clicking outside of it. My solution to open the modal works, closing the modal works too, when the event listeners are added to the page separately. However, they don't work together. When both the listeners are added to the page, the modal won't open. How can I make them to work together? HTML <a href="#openMod

通过点击模式外部来关闭模式

我有一个用CSS构建的模式窗口。 模态可以通过点击外部来关闭。 我的解决方案是打开模式作品,当事件监听器分别添加到页面时,也关闭模式作品。 但是,他们不一起工作。 当两个监听器都添加到页面时,模式将不会打开。 我怎样才能让他们一起工作? HTML <a href="#openModal" id="modal-window" class="event test"> <div class="shorten-long-text test"> </div> </a> <div id="openMo

Javascript is not working after clicking outside of modal window on bootstrap

After clicking outside the modal window, then open again the same modal window. All the functionality I had inside just stopped working. I don't want to prevent the user from clicking outside the modal, any idea on what i can do to avoid this problem? I have the following line of code for calling the modal window: <a href="/samples/edit/{{$sample->project_id}}/{{$sample->id}}"

点击引导模式窗口之外的Javascript后无法工作

在模态窗口外单击后,再次打开相同的模态窗口。 我内部的所有功能都停止工作。 我不想阻止用户在模态外单击,对于我能做什么来避免此问题有任何想法? 我有以下一行代码来调用模态窗口: <a href="/samples/edit/{{$sample->project_id}}/{{$sample->id}}" data-target="#editSample" data-toggle="modal"> {{$sample->name}}</a> 在这里我有一些在模态内执行的JavaScript代码。 $(document).ready(

Catch event of backdrop click on AngularJS modal window

I create a modal window var modalInstance = $modal.open({ templateUrl: 'template.html', controller: app.controller, backdrop: 'static', resolve: { scope: function () { return $scope; } } }); modalInstance.result.then(function (result) { alert("Success"); },

捕捉背景点击AngularJS模态窗口的事件

我创建了一个模式窗口 var modalInstance = $modal.open({ templateUrl: 'template.html', controller: app.controller, backdrop: 'static', resolve: { scope: function () { return $scope; } } }); modalInstance.result.then(function (result) { alert("Success"); }, fu

How to close a modal by clicking outside the modal window?

In a very simple jQuery modal, I close the modal by clicking on CLOSE as $('#close').click(function(e) { e.preventDefault(); $('#overlay, #alertModalOuter').fadeOut(400, function() { $(this).remove(); }); }); How can I close the modal by clicking whether on CLOSE button (which is inside the modal windows) OR clicking anywhere outside the modal window. 像这样改变你的功能应该工作:

如何通过点击模式窗口外部来关闭模式?

在一个非常简单的jQuery模式中,我通过点击CLOSE as关闭模式 $('#close').click(function(e) { e.preventDefault(); $('#overlay, #alertModalOuter').fadeOut(400, function() { $(this).remove(); }); }); 如何关闭模式,方法是单击CLOSE按钮(位于模式窗口内)或者单击模式窗口外的任意位置。 像这样改变你的功能应该工作: $('#close, #overlay').click(function(e) { e.preventDefault(); $('

Close Dialog When Clicked Outside

I have a jQuery UI Dialog that gets displayed when specific elements are clicked. I would like to close the dialog if a click occurs anywhere other than on those triggering elements or the dialog itself. Here's the code for opening the dialog: $(document).ready(function() { var $field_hint = $('<div></div>') .dialog({ autoOpen: false, minHei

单击外部时关闭对话框

我有一个jQuery UI对话框,在点击特定元素时显示。 如果点击发生在除触发元素或对话框本身以外的任何地方,我想关闭对话框。 以下是打开对话框的代码: $(document).ready(function() { var $field_hint = $('<div></div>') .dialog({ autoOpen: false, minHeight: 50, resizable: false, width: 375 }); $('.hint').click(function()

Make sub nav slidedown and slideup toggle

Here's what I'm trying to do: Create a navigation with a sub-nav or child page. When the user clicks on about, I want the about to toggle the Bob li. It should slide down and slide up when clicked on and off of about. $(document).ready(function() { $("#grab").click(function() { $(".sub-nav").slideToggle(); }); });<script src="https://ajax.googleapis.com/ajax/libs/jqu

使子导航滑动并滑动切换

以下是我想要做的事情: 使用子导航或子页面创建导航。 当用户点击时,我想要切换Bob li。 它应该滑下来,并点击左右滑动。 $(document).ready(function() { $("#grab").click(function() { $(".sub-nav").slideToggle(); }); });<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul class="nav"> <li id="#grab">About <ul

Nested lists toggle visibility and :hover effects

I am trying to create a section of navigation that contains menu items that you can click to see a list of other menu items which you can then click on to navigate. So far I have tried using <ul> & <li> which has resulted in this: <ul class="list-unstyled"> <li> <a href="#"><img src="images/Home.png" alt="home image"/></a> <p&

嵌套列表切换可见性和:悬停效果

我正在尝试创建一个包含菜单项的导航部分,您可以单击该菜单项来查看其他菜单项的列表,然后您可以点击进行导航。 到目前为止,我已经尝试使用<ul> & <li> ,其结果如下: <ul class="list-unstyled"> <li> <a href="#"><img src="images/Home.png" alt="home image"/></a> <p>Directories</p> <ul class="list-unstyled">

jQuery text not toggling on first click

I'm trying to toggle text of a span whenever it's parent anchor tag is clicked. Here is the HTML: <h2 class="panel-title"> <a href="#collapse1"> <span class="ui-hidden-accessible">expand</span> </a> </h2> while this is the javascript of the changeText function which is called on each click of the anchor tag function changeText() { va

jQuery文本不会在第一次点击时切换

我试图切换跨度的文本,只要它的父锚标记被点击。 这是HTML: <h2 class="panel-title"> <a href="#collapse1"> <span class="ui-hidden-accessible">expand</span> </a> </h2> 而这是每次点击锚标签时调用的changeText函数的JavaScript function changeText() { var taskDivClass = $('.panel-title a'); $(taskDivClass).each( function() { var $this =

Toggle class to an element by click another element

I want to click on an element to toggle a class being referenced on a completely unrelated element (not a child, parent or sibling) For example, initially the code would look like this <a id="button">Button</a> <div class="navigation"> Foo </div> When the user clicks the element with the id button the HTML would change to look like this (the class "open" is

通过点击另一个元素将类切换为元素

我想单击一个元素来切换一个完全不相关的元素(不是孩子,父母或兄弟姐妹)上引用的类, 例如,最初的代码看起来像这样 <a id="button">Button</a> <div class="navigation"> Foo </div> 当用户点击带有id button的元素时,HTML会变成看起来像这样的类(在已经引用“导航”的元素上引用类“open”: <a id="button">Button</a> <div class="navigation open"> Foo </div>

Toggle instead of going to page with URL

I'm creating different style of navigation in mobile view. The three links that has + sign has their link on desktop view but I want in mobile when clicked, the sub menu will toggle. How can I do that if the 3 links has href? How to prevent the link going to the another page? This is my code $(window).resize(function() { var width = $(document).width(); if (width >= 320) { $("ul#

切换而不是转到使用网址的页面

我在移动视图中创建不同风格的导航。 三个带有+符号的链接在桌面视图上有链接,但是我想在移动时点击,子菜单会切换。 如果3个链接有href,我怎么做? 如何防止链接转到另一个页面? 这是我的代码 $(window).resize(function() { var width = $(document).width(); if (width >= 320) { $("ul#main-menu li").on("click", function() { $(this).next().find('ul.sub-menu').css("display", "block"); $(