label not clickable in jqtouch

若如初见. 提交于 2020-01-21 08:24:24

问题


With following code I can not click on labels in jqtouch (on iphone simulator and iphone itself):

<ul class="rounded">
  <li>
    <label for="user_name">Name</label>
    <input type="text" name="user_name" id="user_name"/>
  </li>
</ul>

It is working well in safari, I have checked this also in demo of jquery-mobile and it is working on iphone simulator, so problem seams to be strictly jqtouch specific.


回答1:


There is an obscure trick for this, using CSS:

label { cursor: pointer; }

And it will work on iPhone and iPad.




回答2:


add onclick="" to the label

<label for="blah" onclick="">blah</label>



回答3:


Tapping on <label> does not auto-focus linked in Mobile Safari




回答4:


thanks to @Ivan I found better solution:

  $('label[for],input[type="radio"]').bind('click', function(e) {
    e.stopPropagation();
  });

Additionally it fixes radio buttons.

The only downside is - it stops propagation, but in my case it is ok.




回答5:


yeah, the user693942 CSS trick is enough, actually, it works!

label { cursor: pointer; }


来源:https://stackoverflow.com/questions/4142520/label-not-clickable-in-jqtouch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!