仅在div中单击

问题描述:

我正在为一个小型网站制作教程.我只想使教程气泡可点击.这样,当我们尝试单击气泡之外的任何东西时,将不会发生任何事情. 换句话说,我希望我的('html')不可点击,而('.tutorial-bubble')-可点击.

I'm making a tutorial for a small website. And I want to make clickable only the tutorial bubble. So that when we try to click something apart of that bubble, nothing will happen. In other words I want my ('html') be unclickable and ('.tutorial-bubble') - clickable.

尝试一下:

jQuery(function($) {

   $('html').on('click', function(e) {
       if($(e.target).attr('class') != 'tutorial-bubble') {
           e.preventDefault();
       }
   }); 

});