简体   繁体   中英

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. 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.

$('#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. You can do it something like this:

HTML:

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

jQuery:

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

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

Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM