Currently, I am utilizing the following Javascript code to implement ontouchstart/move/end callbacks on div elements in an iOS web application. The issue I am facing is that when attempting to scroll through the page, it triggers the ontouchstart event and alters the CSS of the div. What I aim for is to have the CSS changes applied only when a user actually selects the item. My knowledge of Javascript is somewhat basic, so any suggestions on how to modify the code to trigger only when an item is selected would be highly appreciated!
Thank you!
TC
Javascript:
function onclickCallback( event ) {
}
function ontouchstartCallback( event ) {
event.target.className = 'choice_link_selected';
}
function ontouchmoveCallback( event ) {
event.target.className = 'choice_link_selected';
}
function ontouchendCallback( event ) {
event.target.className = 'choice_link';
}
HTML:
<div class="choice_link" onclick="onclickCallback(event);" ontouchstart="ontouchstartCallback(event);" ontouchend="ontouchendCallback(event);" ontouchmove="ontouchmoveCallback(event);">
<a href="javascript:location.href='test.php'">Test</a>
</div>