我创建了一个包含三个选项卡按钮的小型 JQuery 移动应用程序,一个按钮用于访问不同的页面。通过使用预配置的 data-theme="a",按下的按钮在按下时变为蓝色,相关页面被加载。这在第一次单击按钮时有效,但是当第二次单击该按钮以再次访问同一页面(从另一个页面)时,该按钮不会再次变成蓝色,但它仍然是深灰色。有谁知道这个问题的解决方案在哪里? 下面给出了其中一个页面的代码,作为演示。提前致谢
<div data-role="page" data-theme="b" id="chart">
<div data-role="header" data-position="fixed" data-fullscreen="true" class="headerBar" data-theme="a">
<a href="#busstat" data-icon="arrow-l" data-iconpos="left" data-transition="slide" data-direction="reverse" class="back-button">Back</a>
<div align="center" style="vertical-align:middle; margin-top:10px; margin-bottom:10px;">
Cars
</div>
</div>
<div data-role="content" data-fullscreen="true" style="width:100%; height:100%;">
<div id="container" class="container"></div>
</div>
<div data-role="footer" data-position="fixed" data-fullscreen="true" class="footerBar">
<div data-role="navbar">
<ul>
<li><a href="#chartYear" data-role="tab" class="ui-btn-active footer-button" data-transition="slideup" >Last Year</a></li>
<li><a href="#chartMonth" data-role="tab" class="footer-button" data-transition="slideup">Last Month</a></li>
<li><a href="#charWeek" data-role="tab" class="footer-button" data-transition="slideup">Last 7 Days</a></li>
</ul>
</div>
</div>
</div>
最佳答案
将“ui-state-persist”类添加到所选选项卡即可完成工作:
<li><a href="#chartYear" data-role="tab" class="ui-btn-active footer-button ui-state-persist" data-transition="slideup" >Last Year</a></li>
关于jquery - JQuery Mobile 按钮的颜色不会改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15297625/