I’ve got a little question, which I am unable to solve;
I’ve got one div, which onTouchEnd should run a little jquery code (which it does perfectly).
When running this function, it will send the ID of the particular div.
<div id="tapme1" class="subject hold" onTouchEnd="goes(this.id)"></div>
It runs this function:
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 lement = 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);
}
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 lement = 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);
}
As you can tell, this works perfectly. Now comes the problem. I want it to change the div which is clicked. When I turned $('#tapme1') into $(lement) it didn’t do a thing. I’ve tried numerous possibilities.
Hoping any of you can help me with this, appreciated!
You are missing the
#before the id selector.Change
$(lement)to$("#" + lement)