最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Execute default event before custom click function - Stack Overflow

programmeradmin3浏览0评论

I'm trying to execute the default event of a button before executing my custom function

my code:

$('#Button').click( function (){
    sideMenuCheck();
});

I wan't this to be executed after the default event of the function Like this:

$('#Button').click( function (){
    **event.default();**
    sideMenuCheck();
}); 

but I didn't find any solution.


Not important

I'm doing this because I have an off-canvas menu, and menu has to be with the visible height after it opens, (#Button) is the button that opens menu from the side.

I'm trying to execute the default event of a button before executing my custom function

my code:

$('#Button').click( function (){
    sideMenuCheck();
});

I wan't this to be executed after the default event of the function Like this:

$('#Button').click( function (){
    **event.default();**
    sideMenuCheck();
}); 

but I didn't find any solution.


Not important

I'm doing this because I have an off-canvas menu, and menu has to be with the visible height after it opens, (#Button) is the button that opens menu from the side.

Share Improve this question asked Nov 10, 2014 at 11:07 iYazee6iYazee6 86612 silver badges22 bronze badges 1
  • 1 I guess you should instead ask question regarding your former issue, not the workaround you think would fix it – A. Wolff Commented Nov 10, 2014 at 11:24
Add a ment  | 

1 Answer 1

Reset to default 10

You can wrap up your code in a setTimeout with a timeout of 0 - this will cause it to move your code to the bottom of the execution queue, and allow everything else to run first:

$('#Button').click( function (){
    window.setTimeout(function() {
        sideMenuCheck();
    }, 0);
}); 
发布评论

评论列表(0)

  1. 暂无评论