I have encountered a small issue that I am struggling to resolve.
There is one div that should execute a jQuery code on onTouchEnd, and it does so perfectly. The function sends the ID of the specific div.
<div id="tapme1" class="subject hold" onTouchEnd="goes(this.id)"></div>
The function being executed is as follows:
function goes(e) {
var now = new Date().getTime();
var lastTouch = $(this).data('lastTouch') || now + 1 /** the first time this will make delta a negative number */;
var element = e;
var delta = now - lastTouch;
if(delta < 300 && delta > 0) {
if($('#tapme1').hasClass("hold")) {
$('#tapme1').removeClass("hold");
} else {
$('#tapme1').addClass("hold");
}
} else {
// A click/touch action could be invoked here but we need to wait half a second before doing so.
}
$(this).data('lastTouch', now);
}
The above code functions correctly. However, the problem arises when trying to change the clicked div. Replacing $('#tapme1')
with $(element)
did not produce any results despite trying various options.
If anyone can assist me with this, it would be greatly appreciated!