在jquery mobile中使按钮命中区域更大

时间:2014-01-18 05:01:10

标签: ios jquery-mobile cordova

无论如何都要在jquery mobile中使按钮命中区域更大。我在应用程序的标题中有两个按钮,如果我不在中间触摸主题,它们将无法正常工作。

感谢

1 个答案:

答案 0 :(得分:0)

扩展按钮周围的命中区域的一种方法是使用一些填充添加隐藏在按钮周围的包装器。然后将tap事件附加到包装器并在按钮本身上触发tap事件。

这是example

HTML

<div id='button-wrap' style='padding: 20px;'>
    <a id='button' href="#" data-role="button" >Button</a>
</div>

javascript

$('#button-wrap').on('tap', function(e){
    $(this).find('a').trigger('tap');
});

$('#button').on('tap', function(e){
    e.stopPropagation();
    alert('tapped!');
});
相关问题