iPad - touchStart() event blocked by div text
I have a div which triggers a touchStart
event:
<div class="button" ontouchstart="touchStart(event)"> button</div>
When my finger lands on the text button inside the div the event is not triggered, anywhere else on the surface of div event is triggered, how can I make it trig开发者_JAVA技巧ger when I touch the text as well?
if you know the size of the div, then you can add a transparent div above your text with the ontouchstart event.
<div class="buttoncontainer">
<div class="button"> button</div>
<div ontouchstart="touchStart(event)" class="somethingrelative"></div>
</div>
where the buttoncontainer and somethingrelative assist in the positioning.
You can also put the text inside another element, for example a span, and make it unreactive to events with:
.button span {
pointer-events: none;
}
精彩评论