我试图在按下按钮时更改按钮的数据主题。
我在按钮的 onClick 处理程序中调用此 JavaScript 函数:
function changeNextButtonColor() {
var nextButton = document.getElementById('next');
nextButton.setAttribute('data-theme', 'a');
}
但主题没有改变。有任何想法吗?
一旦你在按钮上设置了主题,你需要像下面这样调用“刷新”......
$("#next").attr("data-theme","a").button('refresh');
如果您想将这种行为绑定到进程中的所有“下一个”按钮,并且它们可能不止一个,那么您可能需要考虑做类似这样的事情。它将检查每个页面中是否有一个 colorChangeButton 类的按钮,然后在单击时将主题更改为 data-theme-pressed 按钮属性上指定的备用主题。
<a href="#" data-role="button" class="colorChangeButton" data-theme-pressed="a" data-theme="b">Next</a>
<script type='text/javascript'>
$('div').live('pageinit', function(){
$("a.colorChangeButton).click(function(){
var $thisButton = $(this);
$thisButton.attr("data-theme",$thisButton.attr("data-theme-pressed")).button('refresh');
});
});
</script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)