简体   繁体   中英

Enable the jQuery code below to execute after onClick event anywhere on page

I use the snippet of code below to pause a slider (slider revolution):

jQuery(document).ready(function() {
  jQuery(".rev_slider_wrapper").each(function(){
    $this = jQuery(this);
    id_array = $this.attr("id").split("_");
    id = id_array[2];
    jQuery.globalEval( 'revapi'+id+'.bind("revolution.slide.onloaded",function (e)      {revapi'+id+'.revpause();});' );
  });
});    

How do I make the snippet below to execute only after a click event anywhere on the page?

jQuery(".rev_slider_wrapper").each(function(){
  $this = jQuery(this);
  id_array = $this.attr("id").split("_");
  id = id_array[2];
  jQuery.globalEval( 'revapi'+id+'.revresume();' );
});

Maybe something like this inside your $(document).ready() function:

$("body").click(function(){
  //your code snippet
});

If body does not work try things like document or html

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