我正在使用两个
<li><a href="#" type="button" > text</a></li>
在我的应用程序的页脚导航栏中键入按钮,以触发我的应用程序中的功能(不用于导航)。每次按下后按钮保持按下,直到按下导航栏中的另一个按钮。我该如何避免这种行为?
答案 0 :(得分:1)
另一种处理方法是从事件绑定中返回false,这样JQM就不会在第一时间添加类。
答案 1 :(得分:0)
从上次按下的按钮手动删除班级ui-btn-active
。
$('#button_id').removeClass('ui-btn-active');
EDITED
最好的方法是重新定义类ui-btn-active
的样式,与“未单击”按钮相同。例如:
.ui-footer .ui-navbar .ui-btn-active {
border: 1px solid #222;
background: #333333;
font-weight: bold;
color: #fff;
text-shadow: 0 -1px 1px #000;
background-image: -webkit-gradient(linear, left top, left bottom, from( #555), to( #333));
background-image: -webkit-linear-gradient(#555, #333);
background-image: -moz-linear-gradient(#555, #333);
background-image: -ms-linear-gradient(#555, #333);
background-image: -o-linear-gradient(#555, #333);
background-image: linear-gradient(#555, #333);
}
示例here。
答案 2 :(得分:0)
<button type="button" class="btn btn-default touchbtn">Test</button>
$('.touchbtn').bind('touchstart', function() {
$(this).css('background-color', 'black');
});
$('.touchbtn').bind('touchend', function() {
$(this).css('background-color', 'white');
});