简体   繁体   English

隐藏的div在jQuery中获得焦点时如何触发事件?

[英]how can i trigger event when hidden div get focus in jQuery?

In a tabb design If there are multiple hidden div how can i trigger event when hidden div get focus using jquery. 在Tabb设计中,如果存在多个隐藏的div,当使用jQuery获取隐藏的div的焦点时,如何触发事件。 I tried "focus" but thats for form controls. 我尝试了“焦点”,但这就是表单控件。 please suggest 请建议

You could supply a callback to the show() method, provided you are the one making that call. 您可以向show()方法提供回调,只要您是进行该调用的人即可。

$('#tab1').show('fast', function(){
    // do something now that it is showing
});

It is difficult to focus hidden field. 难以集中隐藏领域。 But I suggest to use opacity as alternative if your existing DIVs code is editable. 但是,如果您现有的DIV代码是可编辑的,我建议使用不透明度作为替代。 You can do it something like this: 您可以这样做:

HTML: HTML:

<div id="hiddendiv" style="height:'200';width:'200'">This is hidden DIV</div>

jQuery: jQuery的:

$('#hiddendiv').stop().animate({ opacity: 0.0 }, 500);

$('#hiddendiv').live('mouseenter', function(){
    $('#hiddendiv').stop().animate({ opacity: 1.0 }, 500);
});

Demo 演示版

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获得焦点事件触发器? - How can I get the focus event trigger? 如何使用jQuery在文本节点上触发焦点事件 - How can you trigger a focus event on a text node using jQuery 如何在jquery中延迟焦点事件? - How can I delay focus event in jquery? 如何通过单击隐藏在 JavaScript 中的 div 来触发函数? - How can I trigger a function by clicking a div which is hidden in JavaScript? 当隐藏的输入框的文本由外部jquery更改时,如何触发函数? - How can I trigger a function when the text of a hidden input box changes by an external jquery? 当悬停在jQuery上时,如何使隐藏的div保持可见? - How to get a hidden div to stay visible when hovered over with jQuery? 当我不知道使用jQuery进行更改的时刻时,会在隐藏字段上触发更改事件? - Trigger change event on hidden field when i don't know the moment of change with jQuery? 如何打开下拉菜单 <select>与焦点jQuery事件? - How can I open a dropdown <select> with focus jquery event? 当用户使用Jquery清除文本字段并将焦点移出文本字段时,如何触发事件? - How to trigger an event when the user clears the text field and focus out of the text field using Jquery? 隐藏元素时如何为div的背景设置动画? - How can I animate the background of a div when an element is hidden?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM