Home > Web Front-end > JS Tutorial > body text

BootStrap implements click area hiding function

PHPz
Release: 2018-10-13 15:24:02
Original
2573 people have browsed it

This time I will bring you BootStrap to implement the click area hiding function. What are the precautions for BootStrap to implement the click area hiding function? The following is a practical case, let's take a look.

When using bootstrap, it is often necessary to add a help button somewhere. When clicked or the mouse is hovered, a help message will be prompted. However, it seems that there is no method provided by bt. If any master knows about bootstrap Some of you can leave a message, I learned from it: The code is as follows

The previous button must be defined as pop;

$(function(){
    $(".pop").popover({placement:'right', trigger:'manual', delay: {show: 10, hide: 10}, html: true,
      title: function () {
        return $("#src-title").html();
      },
      content: function () {
       return $("#data-content").html(); // 把content变成html
      }});
    $('body').click(function (event) {
      var target = $(event.target);    // 判断自己当前点击的内容
      if (!target.hasClass('popover')
          && !target.hasClass('pop')
          && !target.hasClass('popover-content')
          && !target.hasClass('popover-title')
          && !target.hasClass('arrow')) {
        $('.pop').popover('hide');   // 当点击body的非弹出框相关的内容的时候,关闭所有popover
      }
    });
    $(".pop").click(function (event) {
      $('.pop').popover('hide');     // 当点击一个按钮的时候把其他的所有内容先关闭。
      $(this).popover('toggle');     // 然后只把自己打开。
    });
  });
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to Bootstrap tutorial!

Recommended reading:

Detailed explanation of the steps to achieve seamless scrolling effect with vue.js

Created using D3.js Detailed explanation of the steps of logistics map

What are the JS coding standards

The above is the detailed content of BootStrap implements click area hiding function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!