how to add jQuery click event using xPath?

This question already has an answer here: jquery select element by xpath 3 answers How do I detect a click outside an element? 76 answers This might help you. stackoverflow link function _x(STR_XPATH) { var xresult = document.evaluate(STR_XPATH, document, null, XPathResult.ANY_TYPE, null); var xnodes = []; var xres; while (xres = xresult.i

如何使用xPath添加jQuery点击事件?

这个问题在这里已经有了答案: jquery通过xpath选择元素3个答案 如何检测元素外的点击? 76个答案 这可能会帮助你。 stackoverflow链接 function _x(STR_XPATH) { var xresult = document.evaluate(STR_XPATH, document, null, XPathResult.ANY_TYPE, null); var xnodes = []; var xres; while (xres = xresult.iterateNext()) { xnodes.push(xres);

How to know if a clicked element is inside a main one with jQuery?

This question already has an answer here: How do I detect a click outside an element? 76 answers 你可以试试这个 - $(document.body).on('click',function(e){ if(!$(e.target).closest('#main-space').length){ $('#main-space').hide(); } });

如何知道点击元素是否在jQuery的主要元素之内?

这个问题在这里已经有了答案: 如何检测元素外的点击? 76个答案 你可以试试这个 - $(document.body).on('click',function(e){ if(!$(e.target).closest('#main-space').length){ $('#main-space').hide(); } });

Toggle with click effect

Possible Duplicate: How to detect a click outside an element? <ul id="rightNav"> <li id="SettingOpt"> <a href="javascript:void(0)">username<span class="fabShopSprite iRecentIcon iUserIcon"></span></a> <div class="userMenu"> <ul> <li><a class="Setting" href="/">Settings</a></li>

切换点击效果

可能重复: 如何检测元素外的点击? <ul id="rightNav"> <li id="SettingOpt"> <a href="javascript:void(0)">username<span class="fabShopSprite iRecentIcon iUserIcon"></span></a> <div class="userMenu"> <ul> <li><a class="Setting" href="/">Settings</a></li> <li><a

Best way to "click away" from a drop down menu?

Possible Duplicate: How to detect a click outside an element? I have a drop down menu that appears on click. When the user clicks away from it, it disappears. For the on click Im using: $("#title").click(function() { dropdown_show(); ); But when the user clicks away, Im using: $('body').click(function(e) { if ((!$(e.target).is('#title'))&&(!$(e.target).is('#dropdown')))

从下拉菜单中“点击”的最佳方式?

可能重复: 如何检测元素外的点击? 点击时出现一个下拉菜单。 当用户点击它时,它会消失。 对于点击使用Im: $("#title").click(function() { dropdown_show(); ); 但是当用户点击时,我使用: $('body').click(function(e) { if ((!$(e.target).is('#title'))&&(!$(e.target).is('#dropdown'))) { dropdown_hide(); } }); 有没有更好的方法来知道用户何时点击离开,而无需每次用户

detect the click outside of input

This question already has an answer here: How do I detect a click outside an element? 76 answers $(document).on('click', function(e) { if ( e.target.id != 'ok' ) { // you clicked something else } }); That would capture any click except on the input, but why would you need it ? To capture only clicks on .hor-minimalist-a and not the entire document, just replace document wit

检测输入之外的点击

这个问题在这里已经有了答案: 如何检测元素外的点击? 76个答案 $(document).on('click', function(e) { if ( e.target.id != 'ok' ) { // you clicked something else } }); 这将捕获除输入以外的任何点击,但为什么你需要它? 要仅捕获.hor-minimalist-a上的点击,而不是整个文档,只需用上面代码中的该选择器替换document 。 怎么样: $('.hor-minimalist-a').on('click',':not(#ok)',function(){

how to hide div with jquery when click anywhere except one div?

This question already has an answer here: How do I detect a click outside an element? 76 answers $("#search").blur(function(e){ e.stopPropagation() $("#options").fadeOut("fast"); });

如何在除了一个div之外的任何地方点击时用jquery隐藏div?

这个问题在这里已经有了答案: 如何检测元素外的点击? 76个答案 $("#search").blur(function(e){ e.stopPropagation() $("#options").fadeOut("fast"); });

Jquery off click function?

This question already has an answer here: How do I detect a click outside an element? 76 answers This should work for you: $('html').click(function() { $("#navLeft").hide(); }); And then be sure to prevent the event from propagating when clicking the #frame_left element: $("#frame_left").click(function(e) { $("#navLeft").show(); e.stopPropagation(); }); Add a click event for

jquery关闭点击功能?

这个问题在这里已经有了答案: 如何检测元素外的点击? 76个答案 这应该适合你: $('html').click(function() { $("#navLeft").hide(); }); 然后确保在单击#frame_left元素时防止事件传播: $("#frame_left").click(function(e) { $("#navLeft").show(); e.stopPropagation(); }); 为整个文档添加一个点击事件: $(document).click(function(e) { $('#navLeft').hide(); }); 然后停止元素上的传播,因

How to detect clicks outside of a css modal?

This question already has an answer here: How do I detect a click outside an element? 76 answers Probably the simplest way is to bind click event to body and see if it comes from the element (e.target) which has parent (walk up the tree with closest method) .modal : $(document).click(function(e) { if (!$(e.target).closest('.modal').length) { alert('click outside!'); } }); D

如何检测外部的CSS模式点击?

这个问题在这里已经有了答案: 如何检测元素外的点击? 76个答案 可能最简单的方法是将click事件绑定到body,并查看它是否来自具有父级的元素(e.target)(使用closest方法向上走树) .modal : $(document).click(function(e) { if (!$(e.target).closest('.modal').length) { alert('click outside!'); } }); 演示:http://jsfiddle.net/c89Ls0av/4/ 顺便说一下,使用outline制作叠加层是一个有趣的

onClickOut (click after leaving the element)

This question already has an answer here: How do I detect a click outside an element? 76 answers You do that by listening to a click on the document level, and inside the event handler you check if the clicked element was #schnellsuche_box or any element inside #schnellsuche_box by using closest() , like so : $(document).on('click', function(e) { if ( ! $(e.target).closest('#schnellsuch

onClickOut(离开元素后点击)

这个问题在这里已经有了答案: 如何检测元素外的点击? 76个答案 通过监听文档级别的点击,并在事件处理程序内部通过使用#schnellsuche_box closest()来检查单击的元素是#schnellsuche_box还是#schnellsuche_box任何元素,如下所示: $(document).on('click', function(e) { if ( ! $(e.target).closest('#schnellsuche_box').length ) $('#schnellsuche_box').hide(); }); 小提琴 您需要通过return false

If div is not hidden click anywhere to hide

This question already has an answer here: How do I detect a click outside an element? 76 answers placing the entire event handler inside a condition only checks the condition on first pageload, and the event handler is probably never attached, try it like this instead : $('#theDiv').hide(); $(document).on('click', function(e) { if ( $(e.target).closest('#showDivBtn').length ) {

如果div未隐藏,请单击任何位置以隐藏

这个问题在这里已经有了答案: 如何检测元素外的点击? 76个答案 将整个事件处理程序放入一个条件中只会检查第一个页面载入中的条件,并且事件处理程序可能永远不会附加,请尝试如下所示: $('#theDiv').hide(); $(document).on('click', function(e) { if ( $(e.target).closest('#showDivBtn').length ) { $("#theDiv").show(); }else if ( ! $(e.target).closest('#theDiv').length ) { $('#th