我具有以下功能:
function change_mute_status_callback(data, inputs){
show_spinner("#chat-list-option-mute", "revert")
if(data.status != 'success') return
if(data.is_mute){
$("#chat-list-option-mute").attr("src","images/chat/o-mute.svg")
$("#id-"+inputs.chat_id).attr("is-mute","1")
}
else{
$("#chat-list-option-mute").attr("src","images/chat/o-unmute.svg")
$("#id-"+inputs.chat_id).attr("is-mute","0")
}
}
我想使聊天静音和取消静音,当我单击静音图标时,我想更改图像图标,但是第一次更改它,然后不起作用。
有人有任何想法或建议吗?
答案 0 :(得分:0)
尝试将其更改为:
function change_mute_status_callback(data, inputs){
show_spinner("#chat-list-option-mute", "revert")
if(data.status != 'success') return
if(data.is_mute === '0'){// change here
$("#chat-list-option-mute").attr("src","images/chat/o-mute.svg")
$("#id-"+inputs.chat_id).attr("is-mute","1")
}
else{
$("#chat-list-option-mute").attr("src","images/chat/o-unmute.svg")
$("#id-"+inputs.chat_id).attr("is-mute","0")
}
}
当您获得attr is_mute属性时,它将返回字符串,因此始终为true。