简体   繁体   English

touchstart 事件的问题

[英]Problems with touchstart event

I'm building a dynamic section on a website.我正在网站上建立一个动态部分。 When you click or touch the name of one activity, a pop-up displays with the name of that activity and some information.当您单击或触摸一个活动的名称时,会显示一个弹出窗口,其中包含该活动的名称和一些信息。 I've used vanilla JS with one click event and one touchstart event.我已经使用带有一键点击事件和一个 touchstart 事件的 vanilla JS。 It works fine on the first touch but then, when you change to another activity things go wrong.它在第一次触摸时工作正常,但是当您更改为另一个活动时,go 错误。 You can check it here going from one activity to another.您可以在此处从一项活动到另一项活动进行检查。

www.altraves.es/navega www.altraves.es/navega

 function change2h () { activity.innerHTML = "<h2>Navega 2 horas</h2>"; titleDesc.innerHTML = "<div class='et_pb_text_inner'><p>Description of the activity</p></div>" form.value = '0'; finalPrice.innerHTML = 0+'€'; calcPrice(); limitAct(); }; titleTwo.addEventListener('click', change2h); titleTwo.addEventListener('touchstart', change2h);

Could you please help me?请你帮助我好吗? thanks!!谢谢!!

I think that I've fixed it adding preventdefault... Could it be?我想我已经修复了它,添加了 preventdefault... 可以吗?

 function change2h (e) { e.preventDefault(); activity.innerHTML = "<h2>Navega 2 horas</h2>"; titleDesc.innerHTML = "<div class='et_pb_text_inner'><p>Descripción de la actividad</p></div>" form.value = '0'; finalPrice.innerHTML = 0+'€'; calcPrice(); limitAct(); };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM