V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
clivec
V2EX  ›  HTML

一个手机浏览器 ontouchend 小代码的弱智问题求解答

  •  
  •   clivec · Jul 18, 2017 · 3700 views
    This topic created in 3209 days ago, the information mentioned may be changed or developed.
    <div class="weui-form-preview" onclick="if(this.style.backgroundColor=='linen'){this.style.backgroundColor='white'}else{this.style.backgroundColor='linen'}">
    当为 onclick 时在 PC 端 chrome 浏览器上点击相应的 div 能实现变色效果(两种颜色互换),在微信内浏览、在 ios safari 浏览器上及在小米浏览器上浏览均只能变成 linen 色,再次点击不能变成 white 色,就是类似于 onlick 只能执行一次,或 if 程序陷入循环。

    当改为 ontouchend 时在 PC 端上当然没有效果不能执行,在手机端如上所述同样只能变色一次,但后来再加上手机版 firefox 进行测试,能正常变色。

    请问各位大佬应该如何修改才能在各种情况都有同样的表现?
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   845 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 19:43 · PVG 03:43 · LAX 12:43 · JFK 15:43
    ♥ Do have faith in what you're doing.