仅在div中单击 [英] Click only inside div

查看:72
本文介绍了仅在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();
       }
   }); 

});

这篇关于仅在div中单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆