V
V
Vladimir2018-03-14 13:00:39
JavaScript
Vladimir, 2018-03-14 13:00:39

How to change the code so that in the mobile version activation occurs on the second click?

Friends, there is a list with elements. A hover effect hangs on the elements - a red square pops up on the left. When you click on an element, the jQuery toggleClass function is called. The desktop version is great. But when I switch to the mobile version, a problem arises. The fact is that the hover effect in the mobile version is called only by tap, but when I tap on an element, it immediately calls toggleClass. I want that in the mobile version, the first tap only causes the hover of the element (i.e., how to select the element), and when the element is selected, then the toggle is called by a single click. I almost implemented it, but there is an error in the logic of the code, toggle is called by double clicking even when the element is selected.

https://jsfiddle.net/h2dgkzqj/21/

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2018-03-14
@connecticum

https://jsfiddle.net/h2dgkzqj/21/

A
Alexander null, 2018-03-14
@snikes

and if you hang the click event on $(element:hover).click(...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question