我有一些jQuery复选框按钮,他们工作正常。不过,我想通过点击来更改文字。例如:按钮的文字是“点击我”。当用户点击它时,例如,我需要更改为“感谢点击”。jQuery更改复选框按钮文本点击时
这是我使用的尝试:
<script>
$(function() {
$("#button").button();
$("#button").click(function(){
if($("#label").is(':checked')) {
$("#label span").text("Hide");
}
else {
$("#label span").text("Show");
}
});
});
</script>
<input id='button' type='checkbox' />
<label id='label' for="button">Show/Hide</label>