2014-11-06 197 views
2

我在我的網站上使用intro.js瀏覽。我使用bottom作爲默認工具提示位置,但是有沒有辦法在旅程開始後更改工具提示的位置?Intro.js更改工具提示位置

這裏是我的代碼:

tourPluginObject=introJs(); 
    tourPluginObject.onchange(function(targetElement) { 
     if($(targetElement).attr("data-step")==5 && enteredStepFive==false){ 
     enteredStepFive=true;//I entered a step five, so mark this 
     tourPluginObject.setOption('tooltipPosition','left');//Set new tooltip position 
     tourPluginObject.setOption('data-position','left');//Set new tooltip position 
     tourPluginObject.refresh();//Refresh layout 
     } 
    }); 
    tourPluginObject.setOptions({'tooltipPosition': 'bottom' });//Set default tooltip position 
    tourPluginObject.start();//Start tour 

回答

2

如果你可以修改HTML,可以元件5上添加數據屬性data-position="left",並保留其他沒有位置還是將它們全部設置爲「bottom」。

通過這種方式,步驟5將具有所需的位置,而無需在運行時對其進行修改。

+0

爲什麼不使用這裏的選項https://introjs.com/docs/intro/options/ – 2017-11-23 21:39:34