Underline words on mouseover after X seconds

What I'm trying to do is: when you hover over any word in the text for two seconds, it will be underlined. And if you click on it, it will remain underlined until you click anywhere or click it again. Any suggestions?

+3
source share
2 answers

There is no inline event, so you have to split the text and wrap each word in the element. This can become very slow with lots of text.

See How can I highlight every word in jquery so that I can provide a definition for each word?

- http://jsbin.com/ukuza5/3/edit - html p.

0

, <p>, SOL - javascript. , , , , <p> <span> - . JS.

. jQuery

var;

$("span").mouseover(function() {
  timer = timeout(highlight(this), 2000);
});

$("span").mouseout(function() {
  clearTimeout(timer);
});

function underline(jObject) {
  jObject.css("text-decoration", "underline");
}

, , 100% , , , .

+1

Source: https://habr.com/ru/post/1771022/


All Articles