아이폰 사파리에서 간혹
실행되지 않을때가 있다.
간단한 해결법으로는
해당 클릭 이벤트의 tag의 style에
.click_test {
cursor: pointer;
}
를 적용시켜주면 간단히 해결가능하다.
It's important to realize that if you're just using <a>
tags everything will work as expected. You can click or drag by mistake on a regular <a>
link on an iPhone and everything behaves as the user would expect.
I imagine that you have arbitrary HTML that is not clickable - such as a panel containing text and images that cannot be wrapped with <a>
. I found out about this problem when I had such a panel that I wanted to be entirely clickable.
To detect a click anywhere within this div I am using jQuery with a data-href
html attribute which is shown above (this attribute is invented by myself and is not a standard jQuery or HTML data attribute.)
This will work on your desktop browser but not iPad no matter how much you click.
You may be tempted to change your event handler from click
to click touchstart
- and this indeed does trigger the event handler. However if the user wants to drag the page up (to scroll) they'll trigger it too - which is a terrible user experience.
The answer is incredibly simple: Just set the css cursor: pointer
.
그래도 해결되지 않을땐 각각의 onclick 이벤트를 적용시키면 된다.
하지만 onclick이벤트로 수정전에 위의 방법으로 한번 해보는것도 나쁘지않다고 생각한다.
https://stackoverflow.com/questions/3705937/document-click-not-working-correctly-on-iphone-jquery
https://stackoverflow.com/questions/26182194/document-on-functions-not-working-with-safari