Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 按钮不会在电话间隙中单击时更改颜色_Javascript_Jquery_Jquery Mobile_Cordova - Fatal编程技术网

Javascript 按钮不会在电话间隙中单击时更改颜色

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

我是电话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"  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)”。

我尝试过,但在访问链接之前按钮没有闪烁。它只是访问页面,在单击时不显示任何颜色