param属性を変更するこのコードは機能していません。どうしてか言ってくれない?
$("#button").on("click",function(){
if($(this).attr("param") == "Off"){
$(this).attr("param","Play");
}
if($(this).attr("param") == "Play"){
$(this).attr("param","Off");
}
});
param属性を変更するこのコードは機能していません。どうしてか言ってくれない?
$("#button").on("click",function(){
if($(this).attr("param") == "Off"){
$(this).attr("param","Play");
}
if($(this).attr("param") == "Play"){
$(this).attr("param","Off");
}
});
少し遅れていますが、完全なガイドとしてこれを試すことができます
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function(){
$("#but").on("click",function(){
if($(this).attr("param") == "Off"){
$(this).attr("param","Play");
}else if($(this).attr("param") == "Play"){
$(this).attr("param","Off");
}
});
});
</script>
<input type="button" id="but" param="Off" value="go" />
上記の nullability で述べたように、問題は「if else」でした。あなたのコードは初めてそれを変更していましたが、次の瞬間には元に戻していました。