How to make with twitter bootstrap tabs on hover instead of clicking?

前端 未结 6 1870
盖世英雄少女心
盖世英雄少女心 2021-01-31 18:36

I finally got Bootstrap tabs to work. I was wondering if there\'s a way to change the behaviour so instead of clicking just hovering the cursor would show the hidden content?

6条回答
  •  离开以前
    2021-01-31 19:22

    Modify bootstrap.js (or boostrap-tab.js if you aren't using the full bootstrap.js file)

    Where you see:

     /* TAB DATA-API
      * ============ */
    
      $(function () {
        $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
          e.preventDefault()
          $(this).tab('show')
        })
      })
    

    change the 'click.tab.data-api' to 'hover.tab.data-api'

    Note: I tested this with Bootstrap v2.0.2

提交回复
热议问题