label not clickable in jqtouch

2020-03-26 04:09发布

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.

5条回答
Deceive 欺骗
2楼-- · 2020-03-26 04:24

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.

查看更多
Root(大扎)
3楼-- · 2020-03-26 04:25

add onclick="" to the label

<label for="blah" onclick="">blah</label>
查看更多
Ridiculous、
5楼-- · 2020-03-26 04:29

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

label { cursor: pointer; }
查看更多
再贱就再见
6楼-- · 2020-03-26 04:32

There is an obscure trick for this, using CSS:

label { cursor: pointer; }

And it will work on iPhone and iPad.

查看更多
登录 后发表回答