问题
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