5秒后如何在输入时触发工具提示?

时间:2019-02-27 15:31:18

标签: javascript angularjs angularjs-directive tooltip

我目前正在使用Angularjs(版本1.5.8),并且正在开发一个应用程序,该应用程序会动态生成一系列输入,我希望当您专注于输入并且需要5秒钟或更长时间才能开始编写时,出现一个工具提示(所有输入的工具提示均相同),当前,我有一个支持触发事件(“单击”,“ mouseenter”,“焦点”)的工具提示指令。

我使用点击触发器制作了我想要的东西的第一版,但是有时候会有不想要的行为,有什么建议吗?

3 个答案:

答案 0 :(得分:1)

使用mouseenter事件(或focus)并设置超时,以将title属性添加到输入中(或创建要显示的显式工具提示组件)。如果用户有任何keypress或只是普通模型输入,则取消超时吗?

答案 1 :(得分:0)

let input = document.getElementById('input');
input.onfocus = function(){
  let a = 0;
  setTimeout(function(){alert('Please, write something');}, 5000);
};

/* Replaces the function alert('Please ...') with the function that manages your tooltip */
<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <input id="input" />
</body>
</html>

答案 2 :(得分:0)

`

$ scope.focus = function(){

setTimeout(function(){ alert(“ test”); },5000);

您可以在功能内部编写工具提示代码。 您编写了名为element.on(“ focus”)

的自定义指令