IPhone Browser Browser Does Not Observe <label>

Just stumbled upon this recently, and I thought it would be useful to share.

The HTML element is <label>supported in a strange way using the iPhone browser (v3). Try the following:

<input type="checkbox" id="chkTest" /><label for="chkTest">Click me!</label>

By clicking "Click me!" the label does not work, the checkbox is not selected.

The lack of support in the touch device for the elements <label>puzzled me, and I tried to overcome this problem with javascript. The surprise came when I noticed that the void javascript annotation, similar to the one below, also did the trick:

<input type="checkbox" id="chkTest" /><label for="chkTest" onclick="javascript:void(0);">Click me!</label>

NTN

Additional Information:

  • Also works with an empty handler: onclick=""
  • Disabling JavaScript again inactivates the label, even if an empty handler is used.
+3
1

, , CSS , iPhone:

label {cursor: pointer}

+4

Source: https://habr.com/ru/post/1749895/


All Articles