jQuery mobile not going through ID
jQuery mobile not going through ID
我正在制作一个音频应用程序
当我点击播放按钮时,它的id应该动态更改,就像id="paused"一样
然后点击它,它应该会暂停,但这不起作用。
$('#pauses').click(function())
当我点击暂停按钮时,它仍然在播放。
请看一下例子:https://jsfiddle.net/shivam_sh/4zL4en10/2/
您可以进行简单的更改以使其工作。更改您的html添加data-status
<a data-role="button" data-status="play" data-theme="a" id="play" href="#">Play</a>
对于JavaScript代码,您可以这样做。
$('#play').click(function() {
if($(this).data('status') == "play") {
$(this).text("P A U S E");
$(this).data('status', 'pause');
doPlay();
} else {
$(this).text("P L A Y");
$(this).data('status', 'play');
doPause();
}
});
jsfiddle链接此处
p.s:避免对elements
的id
进行修改
相关文章:
- 如何将HTML id分配给元素,以及如何将JavaScript应用于元素
- difference between '$(<%= DDL.ID %>) & $('
- 使用Javascript获取所选选项ID
- 根据id将json数组组合为一个json数组
- 是否有一个JS/jQuery函数可以获取某个类的每个元素的ID
- 对id以某个字符串开头的元素进行计数
- 如果元素's的ID以数字开头
- 通过id和class属性获取元素
- 根据选项卡内部的文本链接中的哈希ID动态选择jqueryUI选项卡
- 使用当前日期生成随机id
- Javascript-ID冲突的几率
- Href:当前DIV中的目标ID
- 无法获取属性'Id'使用Knockout.js的未定义或空引用API
- Javascript复选框函数:;缺少:在属性id之后"
- Twitter引导程序Typeahead-Id&标签
- 如何与特定ID交谈
- chart.series[id].remove()无法刷新高位图表/高位股票中其他系列的图例属性
- 如何在速度模板中获取LiferayPortlet实例id
- jQuery mobile not going through ID
- Looping through JQuery Id's