触发 jQuery 显示焦点不适用于移动设备
triggering jQuery show on focus not working on mobile
当我关注显示 'other' 的复选框时,我触发显示文本区域,因此用户仅在他们从其他复选框中单击该选项时才需要它。 (http://air.abricot-production.com/alliance-of-independent-restaurants/restaurant-membership-application.html).
<script>
$(document).ready(function(){
$(".BusTypeOtherTextArea").hide();
$(".BusTypeOther").focus(function () {
$(".BusTypeOtherTextArea").show("fast");
return false;
});
});
</script>
焦点在桌面上工作正常但在移动设备上不工作?如果我使用 click 它适用于两者,但不会选中复选框。我如何使它适用于移动设备?
我认为解决这个问题的方法是这样的:
$('.checkBox').click(function(){
if($(this).prop('checked')) {
// show textarea
} else {
// hide
}
});
我建议不要使用焦点,尤其是在移动(tablet/phone)设备上没有此手势的情况下。
此解决方案有效:
$(document).ready(function(){
$(".BusTypeOtherTextArea").hide();
$(".BusTypeOther").one('click focus', function() {
$(".BusTypeOtherTextArea").show("fast");
return false;
});
});
当我关注显示 'other' 的复选框时,我触发显示文本区域,因此用户仅在他们从其他复选框中单击该选项时才需要它。 (http://air.abricot-production.com/alliance-of-independent-restaurants/restaurant-membership-application.html).
<script>
$(document).ready(function(){
$(".BusTypeOtherTextArea").hide();
$(".BusTypeOther").focus(function () {
$(".BusTypeOtherTextArea").show("fast");
return false;
});
});
</script>
焦点在桌面上工作正常但在移动设备上不工作?如果我使用 click 它适用于两者,但不会选中复选框。我如何使它适用于移动设备?
我认为解决这个问题的方法是这样的:
$('.checkBox').click(function(){
if($(this).prop('checked')) {
// show textarea
} else {
// hide
}
});
我建议不要使用焦点,尤其是在移动(tablet/phone)设备上没有此手势的情况下。
此解决方案有效:
$(document).ready(function(){
$(".BusTypeOtherTextArea").hide();
$(".BusTypeOther").one('click focus', function() {
$(".BusTypeOtherTextArea").show("fast");
return false;
});
});