2

私はbootstrab.jsを変更しました(クリックをホバーに置き換えただけです):

  $(function () {
    $('body').on('hover.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
      e.preventDefault()
      $(this).tab('show')
    })
  })

タブまたはコンテンツにカーソルを合わせていないときに、コンテンツタブを閉じたいと思います。

どうすればいいですか?

4

1 に答える 1

2

更新:以下のようなもの

var timer;

$('tab_element').hover(
    function(){ //hover
        // clear timer first
        clearTimeout(timer);
        // then show the content
    },
    function(){ //unhovered, 1000 milliseconds
        // set a timer to call the hide function
        timer = setTimeout("hide_function", 1000);
    }
);

$('content_tab_here').bind('mouseleave', function(){
    // hide it, you can set a timer here too if you want
});

これがタイマーに関するドキュメントですhttp://www.w3schools.com/js/js_timing.asp ここには多くのオプションがありますが、これで始められます。私が使用したjqueryは古い学校なので、最新バージョンのjqueryを使用している場合はそれに応じてコードを変更できます。私はあなたのためにすべてを書きたくありません。そうすればあなたは学ばなくなり、私は仕事をしているのでそれほど時間がないからです。幸運を。

于 2012-05-10T17:17:03.633 に答える