jQuery click not working in iOS? -
i have added simple javascript site:
jquery(document).click(function(){ alert('click'); }); ...and fires in ios when clicks on actual anchor element, button element, or on cursor: pointer; css.
specifically, seeing bootstrap 3 fixed navbar menu. when it's open, have added:
jquery(document).click(function(){ jquery('#navbar-collapse.collapse.in').collapse('hide'); }); to ensure closes no matter clicks.
this not working in ios (verified on iphone 4, iphone 6/6+ , ipads).
it seems jquery click events register on "clickable" elements (a, button, etc) or elements cursor: pointer; css or onclick='...something...' or or onclick='' html attributes.
so, question. me? else see this?
by design need use clickable element. yes, experience issue unless take care of solution similar this. if can't expected clicked won't seen way ios.
an excerpt apples developer page.
making elements clickable
because of way safari on ios creates events emulate mouse, of elements may not behave expected on ios. in particular, menus use mousemove handlers, in listing 6-1, need changed because ios doesn’t recognize them clickable elements.
listing 6-1 menu using mouseover handler
<span onmouseover = "..." onmouseout = "..." buy </span> to fix this, add dummy onclick handler, onclick = "void(0)", safari on ios recognizes span element clickable element, shown in listing 6-2.
listing 6-2 adding onclick handler
<span onmouseover = "..." onmouseout = "..." onclick = "void(0)"> buy </span>
Comments
Post a Comment