【问题标题】:create a button that will display mouseover text创建一个显示鼠标悬停文本的按钮
【发布时间】:2014-02-03 05:54:00
【问题描述】:

我知道如何使用鼠标悬停事件创建帮助文本。

但是,这在使用智能手机时不起作用。

有没有办法创建一个按钮,当单击该按钮时,将显示与鼠标悬停帮助文本看起来相同的帮助文本?

【问题讨论】:

标签: html


【解决方案1】:

hover 在移动设备上不存在,我猜你是在用户触摸元素时的意思。如果是这种情况,我认为您有两个选择:


1 (CSS) 使用:active

例子:

Element:active{ /* Stuff to do */ }


2 (Javascript) 使用ontouchstart

Element.ontouchstart = function(e)
{
    //hovering
};

Element.addEventListener('touchstart', function(e)
{
    //Hovering!
});

剩下的就交给你了,因为正如你所说:I know how to create help text with a mouseover event.

【讨论】:

  • 如果它对你有用,请确保你接受这个答案,或者说它没有。
猜你喜欢
  • 2019-09-02
  • 2014-06-30
  • 2013-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多