Javascript 按钮不会在电话间隙中单击时更改颜色
我是电话gap的新手,这是我的代码Javascript 按钮不会在电话间隙中单击时更改颜色,javascript,jquery,jquery-mobile,cordova,Javascript,Jquery,Jquery Mobile,Cordova,我是电话gap的新手,这是我的代码 <div class="ui-grid-a" align="center" style="margin-left: 4px;" > <div class="ui-block-a" data-role="content" style="margin-top: 10px;height: 107px;width: 120px;" align="center"> <a data-role="button" id="btnMyVisit
<div class="ui-grid-a" align="center" style="margin-left: 4px;" >
<div class="ui-block-a" data-role="content" style="margin-top: 10px;height: 107px;width: 120px;" align="center">
<a data-role="button" id="btnMyVisit" data-theme="my-site" style="height: 107px;width: 120px;" data-transition="none" data-mini="true" data-prefetch="true" href="#myVisit">
<img src="img/MyVisit.png" id="myvisitid" style="vertical-align: middle;margin-bottom:0px;margin-left:0px; height: 112px;width: 120px;"> </a>
</div>
我的问题是,每当我单击按钮时,它在访问链接之前不会更改颜色…我希望它在访问之前更改颜色,以便用户知道他刚刚单击了此链接…您可以手动添加类“ui btn active”到用户单击并将更改颜色的按钮。然后只需覆盖“ui btn active”css样式,将其设置为所需的颜色。您可以使用css解决此问题:
.btnMyVisit:active {
// Change something, eg the background color:
background-color: pink;
}
根据您的要求使用以下代码,我相信这会对你有所帮助
function changePage(divId, pageTransition, reverseTransition, changeHash){
var pageTransition1 = typeof(pageTransition) != 'undefined' ? pageTransition : 'none';
var reverseTransition1 = typeof(reverseTransition) != 'undefined' ? reverseTransition : false;
var changeHash1 = typeof(changeHash) != 'undefined' ? changeHash : true;
$.mobile.changePage( '#'+divId, {
transition: pageTransition1,
reverse: reverseTransition1,
changeHash: changeHash1
});
}
$( "#btnMyVisit" ).click(function() {
//this changes the color of your link...
$(this).css('color','red');
setTimeout(function (){
//something you want delayed by 3 sec
// now write code for the event you wanna perform
changePage('myVisit', 'slideup', true, true);
}, 3000);
});
而且
在锚定标记中将href=“#myVisit”更改为href=“javascript:void(0)”。我尝试过,但在访问链接之前按钮没有闪烁。它只是访问页面,在单击时不显示任何颜色