简体   繁体   English

在JS中淡入淡出

[英]Fade in fade out in js

I am working in a cordova android app. 我正在科尔多瓦android应用程序中工作。 Tried with bootstrap. 尝试使用引导程序。 failed. 失败了 hence trying simple js I have a function which returns text to html by 因此尝试简单的js我有一个函数可以通过以下方式将文本返回到html

document.getElementById("temp").innerHTML = Centigrade+"° C , It's Cool !!! "+"<img src= \"img/Tlogo2.svg\"/>";

when I trigger this button: 当我触发此按钮时:

<div style="position: absolute; left: 30px; top: 65px;"> 
    <img src="img/temlogo.svg" width="50" height="50" onclick="foo(myCallback);"/>

</div>

If I want to fade out that text say after 1 min as a pop up by any pop up function (not with alert) then what to do? 如果我想淡出该文本,请说在1分钟后通过任何弹出功能(没有警报)弹出,那么该怎么办?

If bootstrap is possible : http://getbootstrap.com/javascript/#popovers let me know how, not working in my nexus. 如果可以进行引导,请执行以下操作: http : //getbootstrap.com/javascript/#popovers让我知道如何操作,但不能在我的联系中使用。 not getting the themeing and design at all and also in popover, in data container it holding only text, not executing any function 根本没有获得主题和设计,也没有获得弹出框,在data container它仅保存文本,不执行任何功能

Are you trying to create your own pop-over? 您是否要创建自己的弹出窗口? Just initialize or reset a timeout variable whenever the pop-over pops. 弹出窗口弹出时,只需初始化或重置超时变量即可。

function foo(callback) {
    make_the_popover_show();
    popoverTimeout = setTimeout(clearPopover, 1000);
}

function clearPopover() {
    hide_the_popover();
}

Be sure to add identifiers to your pop-overs and to different timeouts, if you plan on showing multiple pop-overs at the same time. 如果计划同时显示多个弹出窗口,请确保将标识符添加到弹出窗口和不同的超时中。

Edit: I forgot to mention i wrote the variable as global. 编辑:我忘了提及我将变量写为全局变量。 But you should write the code the way you like, with or without global vars , and check out how to use Timeouts correctly. 但是, 无论有没有全局var ,您都应该以自己喜欢的方式编写代码,并了解如何正确使用Timeouts

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM