您好我使用以下脚本更改按钮图像以在播放和停止之间切换:
<input type="image" src="../../Content/images/play.png" name="btn" style="width:22; height:22;" />
$(document).ready(function () {
$('#btn').bind("click", function () {
if ($(this).attr("scr") == "../../Content/images/play.png")
$(this).attr("scr", "../../Content/images/puase.png");
else
$(this).attr("scr", "../../Content/images/play.png");
});
});
它不起作用,非常感谢您的建议。
答案 0 :(得分:1)
你应该使用
$('input[name=btn]').bind("click", function () {
并将scr
更改为src
答案 1 :(得分:0)
试试这个:
$(document).ready(function () {
var is_play = true;
$('#btn').click(function () {
if (is_play){
is_play = false;
$(this).attr("src", "../../Content/images/puase.png");
}
else{
$(this).attr("src", "../../Content/images/play.png");
}
});
});
还要将id="btn"
添加到:
<input type="image" id="btn" src="../../Content/images/play.png" name="btn" style="width:22; height:22;" />