【问题标题】:HTML button event on click and releaseHTML button event on click and release
【发布时间】:2022-12-02 08:47:46
【问题描述】:

I'm new on HTML and I need to understand some basic stuff for a project with the ESP01 wi-fi module. I would like to create a web page with a button and this one has to have a different behaviour according to if it is pressed or released.

I tried with this

<button onclick='location.href=&#39;/UP_ON&#39;' onmouseup='location.href=&#39;/UP_OFF&#39;'>UP</button>

but it doesn't work.

【问题讨论】:

  • There is an onmousedown event... Of course, if it does the same thing as onclick, the onmouseup may never fire because you're changing location.href, causing the browser to reload the page....

标签: html esp8266


【解决方案1】:

trylocation.href

 &lt;button onclick='location.href=/?UP_ON' onmouseup='location.href=/?UP_OFF'&gt;UP&lt;/button&gt;

【讨论】:

  • Same thing, the problem is page reload. I'm using arduino libraries and with the server.on function the code understands when a button is pressed, but only if the page is reloaded.
  • i have updated my answer. please check
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-02
  • 1970-01-01
  • 2012-10-06
  • 2017-08-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多